Skip to content

Commit 03ff775

Browse files
authored
Rollup merge of #124928 - okaneco:trim_ascii, r=workingjubilee
Stabilize `byte_slice_trim_ascii` for `&[u8]`/`&str` Remove feature from documentation examples Update intra-doc link for `u8::is_ascii_whitespace` on `&[u8]` functions Closes #94035 FCP has successfully completed #94035 (comment)
2 parents 2259028 + 9fb49fa commit 03ff775

File tree

2 files changed

+15
-21
lines changed

2 files changed

+15
-21
lines changed

library/core/src/slice/ascii.rs

+9-12
Original file line numberDiff line numberDiff line change
@@ -114,18 +114,17 @@ impl [u8] {
114114
/// Returns a byte slice with leading ASCII whitespace bytes removed.
115115
///
116116
/// 'Whitespace' refers to the definition used by
117-
/// `u8::is_ascii_whitespace`.
117+
/// [`u8::is_ascii_whitespace`].
118118
///
119119
/// # Examples
120120
///
121121
/// ```
122-
/// #![feature(byte_slice_trim_ascii)]
123-
///
124122
/// assert_eq!(b" \t hello world\n".trim_ascii_start(), b"hello world\n");
125123
/// assert_eq!(b" ".trim_ascii_start(), b"");
126124
/// assert_eq!(b"".trim_ascii_start(), b"");
127125
/// ```
128-
#[unstable(feature = "byte_slice_trim_ascii", issue = "94035")]
126+
#[stable(feature = "byte_slice_trim_ascii", since = "CURRENT_RUSTC_VERSION")]
127+
#[rustc_const_stable(feature = "byte_slice_trim_ascii", since = "CURRENT_RUSTC_VERSION")]
129128
#[inline]
130129
pub const fn trim_ascii_start(&self) -> &[u8] {
131130
let mut bytes = self;
@@ -144,18 +143,17 @@ impl [u8] {
144143
/// Returns a byte slice with trailing ASCII whitespace bytes removed.
145144
///
146145
/// 'Whitespace' refers to the definition used by
147-
/// `u8::is_ascii_whitespace`.
146+
/// [`u8::is_ascii_whitespace`].
148147
///
149148
/// # Examples
150149
///
151150
/// ```
152-
/// #![feature(byte_slice_trim_ascii)]
153-
///
154151
/// assert_eq!(b"\r hello world\n ".trim_ascii_end(), b"\r hello world");
155152
/// assert_eq!(b" ".trim_ascii_end(), b"");
156153
/// assert_eq!(b"".trim_ascii_end(), b"");
157154
/// ```
158-
#[unstable(feature = "byte_slice_trim_ascii", issue = "94035")]
155+
#[stable(feature = "byte_slice_trim_ascii", since = "CURRENT_RUSTC_VERSION")]
156+
#[rustc_const_stable(feature = "byte_slice_trim_ascii", since = "CURRENT_RUSTC_VERSION")]
159157
#[inline]
160158
pub const fn trim_ascii_end(&self) -> &[u8] {
161159
let mut bytes = self;
@@ -175,18 +173,17 @@ impl [u8] {
175173
/// removed.
176174
///
177175
/// 'Whitespace' refers to the definition used by
178-
/// `u8::is_ascii_whitespace`.
176+
/// [`u8::is_ascii_whitespace`].
179177
///
180178
/// # Examples
181179
///
182180
/// ```
183-
/// #![feature(byte_slice_trim_ascii)]
184-
///
185181
/// assert_eq!(b"\r hello world\n ".trim_ascii(), b"hello world");
186182
/// assert_eq!(b" ".trim_ascii(), b"");
187183
/// assert_eq!(b"".trim_ascii(), b"");
188184
/// ```
189-
#[unstable(feature = "byte_slice_trim_ascii", issue = "94035")]
185+
#[stable(feature = "byte_slice_trim_ascii", since = "CURRENT_RUSTC_VERSION")]
186+
#[rustc_const_stable(feature = "byte_slice_trim_ascii", since = "CURRENT_RUSTC_VERSION")]
190187
#[inline]
191188
pub const fn trim_ascii(&self) -> &[u8] {
192189
self.trim_ascii_start().trim_ascii_end()

library/core/src/str/mod.rs

+6-9
Original file line numberDiff line numberDiff line change
@@ -2531,15 +2531,14 @@ impl str {
25312531
/// # Examples
25322532
///
25332533
/// ```
2534-
/// #![feature(byte_slice_trim_ascii)]
2535-
///
25362534
/// assert_eq!(" \t \u{3000}hello world\n".trim_ascii_start(), "\u{3000}hello world\n");
25372535
/// assert_eq!(" ".trim_ascii_start(), "");
25382536
/// assert_eq!("".trim_ascii_start(), "");
25392537
/// ```
2540-
#[unstable(feature = "byte_slice_trim_ascii", issue = "94035")]
25412538
#[must_use = "this returns the trimmed string as a new slice, \
25422539
without modifying the original"]
2540+
#[stable(feature = "byte_slice_trim_ascii", since = "CURRENT_RUSTC_VERSION")]
2541+
#[rustc_const_stable(feature = "byte_slice_trim_ascii", since = "CURRENT_RUSTC_VERSION")]
25432542
#[inline]
25442543
pub const fn trim_ascii_start(&self) -> &str {
25452544
// SAFETY: Removing ASCII characters from a `&str` does not invalidate
@@ -2557,15 +2556,14 @@ impl str {
25572556
/// # Examples
25582557
///
25592558
/// ```
2560-
/// #![feature(byte_slice_trim_ascii)]
2561-
///
25622559
/// assert_eq!("\r hello world\u{3000}\n ".trim_ascii_end(), "\r hello world\u{3000}");
25632560
/// assert_eq!(" ".trim_ascii_end(), "");
25642561
/// assert_eq!("".trim_ascii_end(), "");
25652562
/// ```
2566-
#[unstable(feature = "byte_slice_trim_ascii", issue = "94035")]
25672563
#[must_use = "this returns the trimmed string as a new slice, \
25682564
without modifying the original"]
2565+
#[stable(feature = "byte_slice_trim_ascii", since = "CURRENT_RUSTC_VERSION")]
2566+
#[rustc_const_stable(feature = "byte_slice_trim_ascii", since = "CURRENT_RUSTC_VERSION")]
25692567
#[inline]
25702568
pub const fn trim_ascii_end(&self) -> &str {
25712569
// SAFETY: Removing ASCII characters from a `&str` does not invalidate
@@ -2584,15 +2582,14 @@ impl str {
25842582
/// # Examples
25852583
///
25862584
/// ```
2587-
/// #![feature(byte_slice_trim_ascii)]
2588-
///
25892585
/// assert_eq!("\r hello world\n ".trim_ascii(), "hello world");
25902586
/// assert_eq!(" ".trim_ascii(), "");
25912587
/// assert_eq!("".trim_ascii(), "");
25922588
/// ```
2593-
#[unstable(feature = "byte_slice_trim_ascii", issue = "94035")]
25942589
#[must_use = "this returns the trimmed string as a new slice, \
25952590
without modifying the original"]
2591+
#[stable(feature = "byte_slice_trim_ascii", since = "CURRENT_RUSTC_VERSION")]
2592+
#[rustc_const_stable(feature = "byte_slice_trim_ascii", since = "CURRENT_RUSTC_VERSION")]
25962593
#[inline]
25972594
pub const fn trim_ascii(&self) -> &str {
25982595
// SAFETY: Removing ASCII characters from a `&str` does not invalidate

0 commit comments

Comments
 (0)