Skip to content

Commit 74039f1

Browse files
committed
DOC: Doc comment and example updates for ArrayVec
1 parent f9b3338 commit 74039f1

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

src/arrayvec.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,11 @@ use crate::arrayvec_impl::ArrayVecImpl;
2626
/// A vector with a fixed capacity.
2727
///
2828
/// The `ArrayVec` is a vector backed by a fixed size array. It keeps track of
29-
/// the number of initialized elements.
29+
/// the number of initialized elements. The `ArrayVec<T, CAP>` is parameterized
30+
/// by `T` for the element type and `CAP` for the maximum capacity.
3031
///
31-
/// The vector is a contiguous value that you can store directly on the stack
32-
/// if needed.
32+
/// The vector is a contiguous value (storing the elements inline) that you can store directly on
33+
/// the stack if needed.
3334
///
3435
/// It offers a simple API but also dereferences to a slice, so
3536
/// that the full slice API is available.
@@ -62,7 +63,7 @@ impl<T, const CAP: usize> ArrayVec<T, CAP> {
6263

6364
/// Create a new empty `ArrayVec`.
6465
///
65-
/// Capacity is inferred from the type parameter.
66+
/// The maximum capacity is given by the generic parameter `CAP`.
6667
///
6768
/// ```
6869
/// use arrayvec::ArrayVec;
@@ -122,7 +123,7 @@ impl<T, const CAP: usize> ArrayVec<T, CAP> {
122123
#[inline(always)]
123124
pub fn capacity(&self) -> usize { CAP }
124125

125-
/// Return if the `ArrayVec` is completely filled.
126+
/// Return ture if the `ArrayVec` is completely filled to its capacity, false otherwise.
126127
///
127128
/// ```
128129
/// use arrayvec::ArrayVec;
@@ -478,7 +479,7 @@ impl<T, const CAP: usize> ArrayVec<T, CAP> {
478479
self.len = length;
479480
}
480481

481-
/// Copy and appends all elements in a slice to the `ArrayVec`.
482+
/// Copy all elements from the slice and append to the `ArrayVec`.
482483
///
483484
/// ```
484485
/// use arrayvec::ArrayVec;
@@ -527,10 +528,10 @@ impl<T, const CAP: usize> ArrayVec<T, CAP> {
527528
/// ```
528529
/// use arrayvec::ArrayVec;
529530
///
530-
/// let mut v = ArrayVec::from([1, 2, 3]);
531-
/// let u: ArrayVec<_, 3> = v.drain(0..2).collect();
532-
/// assert_eq!(&v[..], &[3]);
533-
/// assert_eq!(&u[..], &[1, 2]);
531+
/// let mut v1 = ArrayVec::from([1, 2, 3]);
532+
/// let v2: ArrayVec<_, 3> = v1.drain(0..2).collect();
533+
/// assert_eq!(&v1[..], &[3]);
534+
/// assert_eq!(&v2[..], &[1, 2]);
534535
/// ```
535536
pub fn drain<R>(&mut self, range: R) -> Drain<T, CAP>
536537
where R: RangeBounds<usize>

0 commit comments

Comments
 (0)