Skip to content

Commit b7f65cb

Browse files
committed
Add documentation for all public items
1 parent 8f3198c commit b7f65cb

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

lib.rs

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
1818
#![cfg_attr(not(feature = "std"), no_std)]
1919
#![cfg_attr(not(feature = "std"), feature(alloc))]
20+
#![deny(missing_docs)]
2021

2122

2223
#[cfg(not(feature = "std"))]
@@ -135,6 +136,11 @@ unsafe fn deallocate<T>(ptr: *mut T, capacity: usize) {
135136
// Let it drop.
136137
}
137138

139+
/// An iterator that removes the items from a `SmallVec` and yields them by value.
140+
///
141+
/// Returned from [`SmallVec::drain`][1].
142+
///
143+
/// [1]: struct.SmallVec.html#method.drain
138144
pub struct Drain<'a, T: 'a> {
139145
iter: slice::IterMut<'a,T>,
140146
}
@@ -590,6 +596,8 @@ impl<A: Array> SmallVec<A> {
590596
}
591597
}
592598

599+
/// Insert multiple elements at position `index`, shifting all following elements toward the
600+
/// back.
593601
pub fn insert_many<I: IntoIterator<Item=A::Item>>(&mut self, index: usize, iterable: I) {
594602
let iter = iterable.into_iter();
595603
let (lower_size_bound, _) = iter.size_hint();
@@ -697,12 +705,19 @@ impl<A: Array> SmallVec<A> {
697705
}
698706

699707
impl<A: Array> SmallVec<A> where A::Item: Copy {
708+
/// Copy the elements from a slice into a new `SmallVec`.
709+
///
710+
/// For slices of `Copy` types, this is more efficient than `SmallVec::from(slice)`.
700711
pub fn from_slice(slice: &[A::Item]) -> Self {
701712
let mut vec = Self::new();
702713
vec.extend_from_slice(slice);
703714
vec
704715
}
705716

717+
/// Copy elements from a slice into the vector at position `index`, shifting any following
718+
/// elements toward the back.
719+
///
720+
/// For slices of `Copy` types, this is more efficient than `insert`.
706721
pub fn insert_from_slice(&mut self, index: usize, slice: &[A::Item]) {
707722
self.reserve(slice.len());
708723

@@ -718,6 +733,9 @@ impl<A: Array> SmallVec<A> where A::Item: Copy {
718733
}
719734
}
720735

736+
/// Copy elements from a slice and append them to the vector.
737+
///
738+
/// For slices of `Copy` types, this is more efficient than `extend`.
721739
#[inline]
722740
pub fn extend_from_slice(&mut self, slice: &[A::Item]) {
723741
let len = self.len();
@@ -997,6 +1015,11 @@ impl<A: Array> Hash for SmallVec<A> where A::Item: Hash {
9971015

9981016
unsafe impl<A: Array> Send for SmallVec<A> where A::Item: Send {}
9991017

1018+
/// An iterator that consumes a `SmallVec` and yields its items by value.
1019+
///
1020+
/// Returned from [`SmallVec::into_iter`][1].
1021+
///
1022+
/// [1]: struct.SmallVec.html#method.into_iter
10001023
pub struct IntoIter<A: Array> {
10011024
data: SmallVecData<A>,
10021025
current: usize,
@@ -1116,9 +1139,13 @@ pub type SmallVec32<T> = SmallVec<[T; 32]>;
11161139

11171140
/// Types that can be used as the backing store for a SmallVec
11181141
pub unsafe trait Array {
1142+
/// The type of the array's elements.
11191143
type Item;
1144+
/// Returns the number of items the array can hold.
11201145
fn size() -> usize;
1146+
/// Returns a pointer to the first element of the array.
11211147
fn ptr(&self) -> *const Self::Item;
1148+
/// Returns a mutable pointer to the first element of the array.
11221149
fn ptr_mut(&mut self) -> *mut Self::Item;
11231150
}
11241151

@@ -1140,7 +1167,7 @@ impl_array!(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 20, 24, 32, 3
11401167
0x10000, 0x20000, 0x40000, 0x80000, 0x100000);
11411168

11421169
#[cfg(test)]
1143-
pub mod tests {
1170+
mod tests {
11441171
use SmallVec;
11451172

11461173
use std::iter::FromIterator;

0 commit comments

Comments
 (0)