diff --git a/src/lib.rs b/src/lib.rs index ba4df1e..44835a6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -33,7 +33,7 @@ unsafe fn new_array() -> A { /// A vector with a fixed capacity. /// -/// The **ArrayVec** is a vector backed by a fixed size array. It keeps track of +/// The `ArrayVec` is a vector backed by a fixed size array. It keeps track of /// the number of initialized elements. /// /// The vector is a contiguous value that you can store directly on the stack @@ -61,12 +61,10 @@ impl Drop for ArrayVec { } impl ArrayVec { - /// Create a new empty **ArrayVec**. + /// Create a new empty `ArrayVec`. /// /// Capacity is inferred from the type parameter. /// - /// ## Examples - /// /// ``` /// use arrayvec::ArrayVec; /// @@ -82,9 +80,8 @@ impl ArrayVec { } } - /// Return the number of elements in the **ArrayVec**. + /// Return the number of elements in the `ArrayVec`. /// - /// ## Examples /// ``` /// use arrayvec::ArrayVec; /// @@ -95,9 +92,8 @@ impl ArrayVec { #[inline] pub fn len(&self) -> usize { self.len.to_usize() } - /// Return the capacity of the **ArrayVec**. + /// Return the capacity of the `ArrayVec`. /// - /// ## Examples /// ``` /// use arrayvec::ArrayVec; /// @@ -107,12 +103,11 @@ impl ArrayVec { #[inline] pub fn capacity(&self) -> usize { A::capacity() } - /// Push **element** to the end of the vector. + /// Push `element` to the end of the vector. /// - /// Return **None** if the push succeeds, or and return **Some(** *element* **)** + /// Return `None` if the push succeeds, or and return `Some(` *element* `)` /// if the vector is full. /// - /// ## Examples /// ``` /// use arrayvec::ArrayVec; /// @@ -140,9 +135,8 @@ impl ArrayVec { /// Remove the last element in the vector. /// - /// Return **Some(** *element* **)** if the vector is non-empty, else **None**. + /// Return `Some(` *element* `)` if the vector is non-empty, else `None`. /// - /// ## Examples /// ``` /// use arrayvec::ArrayVec; /// @@ -164,13 +158,12 @@ impl ArrayVec { } } - /// Insert **element** in position **index**. + /// Insert `element` in position `index`. /// - /// Shift up all elements after **index**. If any is pushed out, it is returned. + /// Shift up all elements after `index`. If any is pushed out, it is returned. /// - /// Return None if no element is shifted out. + /// Return `None` if no element is shifted out. /// - /// ## Examples /// ``` /// use arrayvec::ArrayVec; /// @@ -211,13 +204,12 @@ impl ArrayVec { ret } - /// Remove the element at **index** and swap the last element into its place. + /// Remove the element at `index` and swap the last element into its place. /// /// This operation is O(1). /// - /// Return **Some(** *element* **)** if the index is in bounds, else **None**. + /// Return `Some(` *element* `)` if the index is in bounds, else `None`. /// - /// ## Examples /// ``` /// use arrayvec::ArrayVec; /// @@ -237,11 +229,10 @@ impl ArrayVec { self.pop() } - /// Remove the element at **index** and shift down the following elements. + /// Remove the element at `index` and shift down the following elements. /// - /// Return **Some(** *element* **)** if the index is in bounds, else **None**. + /// Return `Some(` *element* `)` if the index is in bounds, else `None`. /// - /// ## Examples /// ``` /// use arrayvec::ArrayVec; /// @@ -267,9 +258,9 @@ impl ArrayVec { /// Set the vector's length without dropping or moving out elements /// - /// May panic if **length** is greater than the capacity. + /// May panic if `length` is greater than the capacity. /// - /// This function is **unsafe** because it changes the notion of the + /// This function is `unsafe` because it changes the notion of the /// number of “valid” elements in the vector. Use with care. #[inline] pub unsafe fn set_len(&mut self, length: usize) { @@ -285,13 +276,9 @@ impl ArrayVec { /// Note: It is unspecified how many elements are removed from the vector, /// if the `Drain` value is leaked. /// - /// # Panics - /// - /// Panics if the starting point is greater than the end point or if + /// **Panics** if the starting point is greater than the end point or if /// the end point is greater than the length of the vector. /// - /// # Examples - /// /// ``` /// use arrayvec::ArrayVec; /// @@ -331,10 +318,10 @@ impl ArrayVec { /// Return the inner fixed size array, if it is full to its capacity. /// - /// Return an **Ok** value with the array if length equals capacity, - /// return an **Err** with self otherwise. + /// Return an `Ok` value with the array if length equals capacity, + /// return an `Err` with self otherwise. /// - /// **Note:** This function may incur unproportionally large overhead + /// `Note:` This function may incur unproportionally large overhead /// to move the array out, its performance is not optimal. pub fn into_inner(self) -> Result { if self.len() < self.capacity() { @@ -369,9 +356,8 @@ impl DerefMut for ArrayVec { } } -/// Create an **ArrayVec** from an array. +/// Create an `ArrayVec` from an array. /// -/// ## Examples /// ``` /// use arrayvec::ArrayVec; /// @@ -386,9 +372,7 @@ impl From for ArrayVec { } -/// Iterate the **ArrayVec** with references to each element. -/// -/// ## Examples +/// Iterate the `ArrayVec` with references to each element. /// /// ``` /// use arrayvec::ArrayVec; @@ -405,9 +389,7 @@ impl<'a, A: Array> IntoIterator for &'a ArrayVec { fn into_iter(self) -> Self::IntoIter { self.iter() } } -/// Iterate the **ArrayVec** with mutable references to each element. -/// -/// ## Examples +/// Iterate the `ArrayVec` with mutable references to each element. /// /// ``` /// use arrayvec::ArrayVec; @@ -424,12 +406,10 @@ impl<'a, A: Array> IntoIterator for &'a mut ArrayVec { fn into_iter(self) -> Self::IntoIter { self.iter_mut() } } -/// Iterate the **ArrayVec** with each element by value. +/// Iterate the `ArrayVec` with each element by value. /// /// The vector is consumed by this operation. /// -/// ## Examples -/// /// ``` /// use arrayvec::ArrayVec; /// @@ -446,7 +426,7 @@ impl IntoIterator for ArrayVec { } -/// By-value iterator for **ArrayVec**. +/// By-value iterator for `ArrayVec`. pub struct IntoIter { index: A::Index, v: ArrayVec, @@ -507,7 +487,7 @@ impl Drop for IntoIter { } } -/// A draining iterator for **ArrayVec**. +/// A draining iterator for `ArrayVec`. pub struct Drain<'a, A> where A: Array, A::Item: 'a, @@ -586,7 +566,7 @@ impl<'a, A: Array> Drop for Drain<'a, A> -/// Extend the **ArrayVec** with an iterator. +/// Extend the `ArrayVec` with an iterator. /// /// Does not extract more items than there is space for. No error /// occurs if there are more iterator elements. @@ -599,7 +579,7 @@ impl Extend for ArrayVec { } } -/// Create an **ArrayVec** from an iterator. +/// Create an `ArrayVec` from an iterator. /// /// Does not extract more items than there is space for. No error /// occurs if there are more iterator elements.