Skip to content

Commit

Permalink
Stabilize byte_slice_trim_ascii for &[u8]/&str
Browse files Browse the repository at this point in the history
Remove feature from documentation examples
Update intra-doc link for `u8::is_ascii_whitespace` on `&[u8]` functions
  • Loading branch information
okaneco committed May 9, 2024
1 parent 6f7e00a commit a68ae32
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 21 deletions.
24 changes: 12 additions & 12 deletions library/core/src/slice/ascii.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,18 +114,18 @@ impl [u8] {
/// Returns a byte slice with leading ASCII whitespace bytes removed.
///
/// 'Whitespace' refers to the definition used by
/// `u8::is_ascii_whitespace`.
/// [`u8::is_ascii_whitespace`].
///
/// [`u8::is_ascii_whitespace`]: u8::is_ascii_whitespace
///
/// # Examples
///
/// ```
/// #![feature(byte_slice_trim_ascii)]
///
/// assert_eq!(b" \t hello world\n".trim_ascii_start(), b"hello world\n");
/// assert_eq!(b" ".trim_ascii_start(), b"");
/// assert_eq!(b"".trim_ascii_start(), b"");
/// ```
#[unstable(feature = "byte_slice_trim_ascii", issue = "94035")]
#[stable(feature = "byte_slice_trim_ascii", since = "CURRENT_RUSTC_VERSION")]
#[inline]
pub const fn trim_ascii_start(&self) -> &[u8] {
let mut bytes = self;
Expand All @@ -144,18 +144,18 @@ impl [u8] {
/// Returns a byte slice with trailing ASCII whitespace bytes removed.
///
/// 'Whitespace' refers to the definition used by
/// `u8::is_ascii_whitespace`.
/// [`u8::is_ascii_whitespace`].
///
/// [`u8::is_ascii_whitespace`]: u8::is_ascii_whitespace
///
/// # Examples
///
/// ```
/// #![feature(byte_slice_trim_ascii)]
///
/// assert_eq!(b"\r hello world\n ".trim_ascii_end(), b"\r hello world");
/// assert_eq!(b" ".trim_ascii_end(), b"");
/// assert_eq!(b"".trim_ascii_end(), b"");
/// ```
#[unstable(feature = "byte_slice_trim_ascii", issue = "94035")]
#[stable(feature = "byte_slice_trim_ascii", since = "CURRENT_RUSTC_VERSION")]
#[inline]
pub const fn trim_ascii_end(&self) -> &[u8] {
let mut bytes = self;
Expand All @@ -175,18 +175,18 @@ impl [u8] {
/// removed.
///
/// 'Whitespace' refers to the definition used by
/// `u8::is_ascii_whitespace`.
/// [`u8::is_ascii_whitespace`].
///
/// [`u8::is_ascii_whitespace`]: u8::is_ascii_whitespace
///
/// # Examples
///
/// ```
/// #![feature(byte_slice_trim_ascii)]
///
/// assert_eq!(b"\r hello world\n ".trim_ascii(), b"hello world");
/// assert_eq!(b" ".trim_ascii(), b"");
/// assert_eq!(b"".trim_ascii(), b"");
/// ```
#[unstable(feature = "byte_slice_trim_ascii", issue = "94035")]
#[stable(feature = "byte_slice_trim_ascii", since = "CURRENT_RUSTC_VERSION")]
#[inline]
pub const fn trim_ascii(&self) -> &[u8] {
self.trim_ascii_start().trim_ascii_end()
Expand Down
12 changes: 3 additions & 9 deletions library/core/src/str/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2531,13 +2531,11 @@ impl str {
/// # Examples
///
/// ```
/// #![feature(byte_slice_trim_ascii)]
///
/// assert_eq!(" \t \u{3000}hello world\n".trim_ascii_start(), "\u{3000}hello world\n");
/// assert_eq!(" ".trim_ascii_start(), "");
/// assert_eq!("".trim_ascii_start(), "");
/// ```
#[unstable(feature = "byte_slice_trim_ascii", issue = "94035")]
#[stable(feature = "byte_slice_trim_ascii", since = "CURRENT_RUSTC_VERSION")]
#[must_use = "this returns the trimmed string as a new slice, \
without modifying the original"]
#[inline]
Expand All @@ -2557,13 +2555,11 @@ impl str {
/// # Examples
///
/// ```
/// #![feature(byte_slice_trim_ascii)]
///
/// assert_eq!("\r hello world\u{3000}\n ".trim_ascii_end(), "\r hello world\u{3000}");
/// assert_eq!(" ".trim_ascii_end(), "");
/// assert_eq!("".trim_ascii_end(), "");
/// ```
#[unstable(feature = "byte_slice_trim_ascii", issue = "94035")]
#[stable(feature = "byte_slice_trim_ascii", since = "CURRENT_RUSTC_VERSION")]
#[must_use = "this returns the trimmed string as a new slice, \
without modifying the original"]
#[inline]
Expand All @@ -2584,13 +2580,11 @@ impl str {
/// # Examples
///
/// ```
/// #![feature(byte_slice_trim_ascii)]
///
/// assert_eq!("\r hello world\n ".trim_ascii(), "hello world");
/// assert_eq!(" ".trim_ascii(), "");
/// assert_eq!("".trim_ascii(), "");
/// ```
#[unstable(feature = "byte_slice_trim_ascii", issue = "94035")]
#[stable(feature = "byte_slice_trim_ascii", since = "CURRENT_RUSTC_VERSION")]
#[must_use = "this returns the trimmed string as a new slice, \
without modifying the original"]
#[inline]
Expand Down

0 comments on commit a68ae32

Please sign in to comment.