Skip to content

Commit

Permalink
Fix doc nits
Browse files Browse the repository at this point in the history
Many tiny changes to stdlib doc comments to make them consistent (for example
"Returns foo", rather than "Return foo", per RFC1574), adding missing periods, paragraph
breaks, backticks for monospace style, and other minor nits.

https://github.com/rust-lang/rfcs/blob/master/text/1574-more-api-documentation-conventions.md#appendix-a-full-conventions-text
  • Loading branch information
bitfield committed Jul 26, 2024
1 parent b173176 commit 048ba3e
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 23 deletions.
12 changes: 6 additions & 6 deletions crates/core_simd/src/masks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ where
T: MaskElement,
LaneCount<N>: SupportedLaneCount,
{
/// Construct a mask by setting all elements to the given value.
/// Constructs a mask by setting all elements to the given value.
#[inline]
pub fn splat(value: bool) -> Self {
Self(mask_impl::Mask::splat(value))
Expand Down Expand Up @@ -288,7 +288,7 @@ where
self.0.all()
}

/// Create a bitmask from a mask.
/// Creates a bitmask from a mask.
///
/// Each bit is set if the corresponding element in the mask is `true`.
/// If the mask contains more than 64 elements, the bitmask is truncated to the first 64.
Expand All @@ -298,7 +298,7 @@ where
self.0.to_bitmask_integer()
}

/// Create a mask from a bitmask.
/// Creates a mask from a bitmask.
///
/// For each bit, if it is set, the corresponding element in the mask is set to `true`.
/// If the mask contains more than 64 elements, the remainder are set to `false`.
Expand All @@ -308,7 +308,7 @@ where
Self(mask_impl::Mask::from_bitmask_integer(bitmask))
}

/// Create a bitmask vector from a mask.
/// Creates a bitmask vector from a mask.
///
/// Each bit is set if the corresponding element in the mask is `true`.
/// The remaining bits are unset.
Expand All @@ -328,7 +328,7 @@ where
self.0.to_bitmask_vector()
}

/// Create a mask from a bitmask vector.
/// Creates a mask from a bitmask vector.
///
/// For each bit, if it is set, the corresponding element in the mask is set to `true`.
///
Expand All @@ -350,7 +350,7 @@ where
Self(mask_impl::Mask::from_bitmask_vector(bitmask))
}

/// Find the index of the first set element.
/// Finds the index of the first set element.
///
/// ```
/// # #![feature(portable_simd)]
Expand Down
2 changes: 1 addition & 1 deletion crates/core_simd/src/simd/ptr/const_ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pub trait SimdConstPtr: Copy + Sealed {
/// [`Self::with_exposed_provenance`] and returns the "address" portion.
fn expose_provenance(self) -> Self::Usize;

/// Convert an address back to a pointer, picking up a previously "exposed" provenance.
/// Converts an address back to a pointer, picking up a previously "exposed" provenance.
///
/// Equivalent to calling [`core::ptr::with_exposed_provenance`] on each element.
fn with_exposed_provenance(addr: Self::Usize) -> Self;
Expand Down
2 changes: 1 addition & 1 deletion crates/core_simd/src/simd/ptr/mut_ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub trait SimdMutPtr: Copy + Sealed {
/// [`Self::with_exposed_provenance`] and returns the "address" portion.
fn expose_provenance(self) -> Self::Usize;

/// Convert an address back to a pointer, picking up a previously "exposed" provenance.
/// Converts an address back to a pointer, picking up a previously "exposed" provenance.
///
/// Equivalent to calling [`core::ptr::with_exposed_provenance_mut`] on each element.
fn with_exposed_provenance(addr: Self::Usize) -> Self;
Expand Down
10 changes: 5 additions & 5 deletions crates/core_simd/src/swizzle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ pub macro simd_swizzle {
}
}

/// Create a vector from the elements of another vector.
/// Creates a vector from the elements of another vector.
pub trait Swizzle<const N: usize> {
/// Map from the elements of the input vector to the output vector.
const INDEX: [usize; N];

/// Create a new vector from the elements of `vector`.
/// Creates a new vector from the elements of `vector`.
///
/// Lane `i` of the output is `vector[Self::INDEX[i]]`.
#[inline]
Expand Down Expand Up @@ -109,7 +109,7 @@ pub trait Swizzle<const N: usize> {
}
}

/// Create a new vector from the elements of `first` and `second`.
/// Creates a new vector from the elements of `first` and `second`.
///
/// Lane `i` of the output is `concat[Self::INDEX[i]]`, where `concat` is the concatenation of
/// `first` and `second`.
Expand Down Expand Up @@ -145,7 +145,7 @@ pub trait Swizzle<const N: usize> {
}
}

/// Create a new mask from the elements of `mask`.
/// Creates a new mask from the elements of `mask`.
///
/// Element `i` of the output is `concat[Self::INDEX[i]]`, where `concat` is the concatenation of
/// `first` and `second`.
Expand All @@ -161,7 +161,7 @@ pub trait Swizzle<const N: usize> {
unsafe { Mask::from_int_unchecked(Self::swizzle(mask.to_int())) }
}

/// Create a new mask from the elements of `first` and `second`.
/// Creates a new mask from the elements of `first` and `second`.
///
/// Element `i` of the output is `concat[Self::INDEX[i]]`, where `concat` is the concatenation of
/// `first` and `second`.
Expand Down
14 changes: 7 additions & 7 deletions crates/core_simd/src/to_bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ mod sealed {
}
use sealed::Sealed;

/// Convert SIMD vectors to vectors of bytes
/// Converts SIMD vectors to vectors of bytes
pub trait ToBytes: Sealed {
/// This type, reinterpreted as bytes.
type Bytes: Copy
Expand All @@ -22,26 +22,26 @@ pub trait ToBytes: Sealed {
+ SimdUint<Scalar = u8>
+ 'static;

/// Return the memory representation of this integer as a byte array in native byte
/// Returns the memory representation of this integer as a byte array in native byte
/// order.
fn to_ne_bytes(self) -> Self::Bytes;

/// Return the memory representation of this integer as a byte array in big-endian
/// Returns the memory representation of this integer as a byte array in big-endian
/// (network) byte order.
fn to_be_bytes(self) -> Self::Bytes;

/// Return the memory representation of this integer as a byte array in little-endian
/// Returns the memory representation of this integer as a byte array in little-endian
/// byte order.
fn to_le_bytes(self) -> Self::Bytes;

/// Create a native endian integer value from its memory representation as a byte array
/// Creates a native endian integer value from its memory representation as a byte array
/// in native endianness.
fn from_ne_bytes(bytes: Self::Bytes) -> Self;

/// Create an integer value from its representation as a byte array in big endian.
/// Creates an integer value from its representation as a byte array in big endian.
fn from_be_bytes(bytes: Self::Bytes) -> Self;

/// Create an integer value from its representation as a byte array in little endian.
/// Creates an integer value from its representation as a byte array in little endian.
fn from_le_bytes(bytes: Self::Bytes) -> Self;
}

Expand Down
6 changes: 3 additions & 3 deletions crates/core_simd/src/vector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ where
unsafe { &mut *(self as *mut Self as *mut [T; N]) }
}

/// Load a vector from an array of `T`.
/// Loads a vector from an array of `T`.
///
/// This function is necessary since `repr(simd)` has padding for non-power-of-2 vectors (at the time of writing).
/// With padding, `read_unaligned` will read past the end of an array of N elements.
Expand Down Expand Up @@ -567,7 +567,7 @@ where
unsafe { Self::gather_select_ptr(ptrs, enable, or) }
}

/// Read elementwise from pointers into a SIMD vector.
/// Reads elementwise from pointers into a SIMD vector.
///
/// # Safety
///
Expand Down Expand Up @@ -808,7 +808,7 @@ where
}
}

/// Write pointers elementwise into a SIMD vector.
/// Writes pointers elementwise into a SIMD vector.
///
/// # Safety
///
Expand Down

0 comments on commit 048ba3e

Please sign in to comment.