From 43541f432b94fad09695a93ae2c851396f914dc4 Mon Sep 17 00:00:00 2001 From: Bruce Mitchener Date: Sun, 8 Oct 2023 00:58:01 +0700 Subject: [PATCH] Minor tweaks to doc formatting. --- src/lib.rs | 22 +++++++++++----------- src/tests.rs | 4 ++-- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index bf530a7..c37e0ef 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -328,7 +328,7 @@ fn infallible(result: Result) -> T { } /// FIXME: use `Layout::array` when we require a Rust version where it’s stable -/// https://github.com/rust-lang/rust/issues/55724 +/// fn layout_array(n: usize) -> Result { let size = mem::size_of::() .checked_mul(n) @@ -815,7 +815,7 @@ impl SmallVec { /// Construct a new `SmallVec` from a `Vec`. /// - /// Elements will be copied to the inline buffer if vec.capacity() <= Self::inline_capacity(). + /// Elements will be copied to the inline buffer if `vec.capacity() <= Self::inline_capacity()`. /// /// ```rust /// use smallvec::SmallVec; @@ -970,7 +970,7 @@ impl SmallVec { } /// Returns a tuple with (data ptr, len, capacity) - /// Useful to get all SmallVec properties with a single check of the current storage variant. + /// Useful to get all `SmallVec` properties with a single check of the current storage variant. #[inline] fn triple(&self) -> (ConstNonNull, usize, usize) { unsafe { @@ -1475,7 +1475,7 @@ impl SmallVec { } } - /// Convert a SmallVec to a Vec, without reallocating if the SmallVec has already spilled onto + /// Convert a `SmallVec` to a `Vec`, without reallocating if the `SmallVec` has already spilled onto /// the heap. pub fn into_vec(mut self) -> Vec { if self.spilled() { @@ -1498,10 +1498,10 @@ impl SmallVec { self.into_vec().into_boxed_slice() } - /// Convert the SmallVec into an `A` if possible. Otherwise return `Err(Self)`. + /// Convert the `SmallVec` into an `A` if possible. Otherwise return `Err(Self)`. /// - /// This method returns `Err(Self)` if the SmallVec is too short (and the `A` contains uninitialized elements), - /// or if the SmallVec is too long (and all the elements were spilled to the heap). + /// This method returns `Err(Self)` if the `SmallVec` is too short (and the `A` contains uninitialized elements), + /// or if the `SmallVec` is too long (and all the elements were spilled to the heap). pub fn into_inner(self) -> Result { if self.spilled() || self.len() != A::size() { // Note: A::size, not Self::inline_capacity @@ -1595,7 +1595,7 @@ impl SmallVec { /// /// If `new_len` is greater than `len`, the `SmallVec` is extended by the difference, with each /// additional slot filled with the result of calling the closure `f`. The return values from `f` - //// will end up in the `SmallVec` in the order they have been generated. + /// will end up in the `SmallVec` in the order they have been generated. /// /// If `new_len` is less than `len`, the `SmallVec` is simply truncated. /// @@ -1603,7 +1603,7 @@ impl SmallVec { /// value, use `resize`. If you want to use the `Default` trait to generate values, you can pass /// `Default::default()` as the second argument. /// - /// Added for std::vec::Vec compatibility (added in Rust 1.33.0) + /// Added for `std::vec::Vec` compatibility (added in Rust 1.33.0) /// /// ``` /// # use smallvec::{smallvec, SmallVec}; @@ -2321,7 +2321,7 @@ impl<'a, A: Array> IntoIterator for &'a mut SmallVec { } } -/// Types that can be used as the backing store for a SmallVec +/// Types that can be used as the backing store for a [`SmallVec`]. pub unsafe trait Array { /// The type of the array's elements. type Item; @@ -2331,7 +2331,7 @@ pub unsafe trait Array { /// Set the length of the vec when the `SetLenOnDrop` value goes out of scope. /// -/// Copied from https://github.com/rust-lang/rust/pull/36355 +/// Copied from struct SetLenOnDrop<'a> { len: &'a mut usize, local_len: usize, diff --git a/src/tests.rs b/src/tests.rs index bb39dde..698f453 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -72,13 +72,13 @@ pub fn test_double_spill() { ); } -/// https://github.com/servo/rust-smallvec/issues/4 +// https://github.com/servo/rust-smallvec/issues/4 #[test] fn issue_4() { SmallVec::<[Box; 2]>::new(); } -/// https://github.com/servo/rust-smallvec/issues/5 +// https://github.com/servo/rust-smallvec/issues/5 #[test] fn issue_5() { assert!(Some(SmallVec::<[&u32; 2]>::new()).is_some());