Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor tweaks to doc formatting. #318

Merged
merged 1 commit into from
Oct 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ fn infallible<T>(result: Result<T, CollectionAllocErr>) -> T {
}

/// FIXME: use `Layout::array` when we require a Rust version where it’s stable
/// https://github.com/rust-lang/rust/issues/55724
/// <https://github.com/rust-lang/rust/issues/55724>
fn layout_array<T>(n: usize) -> Result<Layout, CollectionAllocErr> {
let size = mem::size_of::<T>()
.checked_mul(n)
Expand Down Expand Up @@ -815,7 +815,7 @@ impl<A: Array> SmallVec<A> {

/// Construct a new `SmallVec` from a `Vec<A::Item>`.
///
/// 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;
Expand Down Expand Up @@ -970,7 +970,7 @@ impl<A: Array> SmallVec<A> {
}

/// 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<A::Item>, usize, usize) {
unsafe {
Expand Down Expand Up @@ -1475,7 +1475,7 @@ impl<A: Array> SmallVec<A> {
}
}

/// 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<A::Item> {
if self.spilled() {
Expand All @@ -1498,10 +1498,10 @@ impl<A: Array> SmallVec<A> {
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<A, Self> {
if self.spilled() || self.len() != A::size() {
// Note: A::size, not Self::inline_capacity
Expand Down Expand Up @@ -1595,15 +1595,15 @@ impl<A: Array> SmallVec<A> {
///
/// 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.
///
/// This method uses a closure to create new values on every push. If you'd rather `Clone` a given
/// 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};
Expand Down Expand Up @@ -2321,7 +2321,7 @@ impl<'a, A: Array> IntoIterator for &'a mut SmallVec<A> {
}
}

/// 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;
Expand All @@ -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 <https://github.com/rust-lang/rust/pull/36355>
struct SetLenOnDrop<'a> {
len: &'a mut usize,
local_len: usize,
Expand Down
4 changes: 2 additions & 2 deletions src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u32>; 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());
Expand Down