Skip to content

Commit 69ae958

Browse files
committed
Stabilize byte_slice_trim_ascii for &[u8]/&str
Remove feature from documentation examples Add rustc_const_stable attribute to stabilized functions Update intra-doc link for `u8::is_ascii_whitespace` on `&[u8]` functions
1 parent 6f7e00a commit 69ae958

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

library/core/src/slice/ascii.rs

+15-12
Original file line numberDiff line numberDiff line change
@@ -114,18 +114,19 @@ 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`].
118+
///
119+
/// [`u8::is_ascii_whitespace`]: u8::is_ascii_whitespace
118120
///
119121
/// # Examples
120122
///
121123
/// ```
122-
/// #![feature(byte_slice_trim_ascii)]
123-
///
124124
/// assert_eq!(b" \t hello world\n".trim_ascii_start(), b"hello world\n");
125125
/// assert_eq!(b" ".trim_ascii_start(), b"");
126126
/// assert_eq!(b"".trim_ascii_start(), b"");
127127
/// ```
128-
#[unstable(feature = "byte_slice_trim_ascii", issue = "94035")]
128+
#[stable(feature = "byte_slice_trim_ascii", since = "CURRENT_RUSTC_VERSION")]
129+
#[rustc_const_stable(feature = "byte_slice_trim_ascii", since = "CURRENT_RUSTC_VERSION")]
129130
#[inline]
130131
pub const fn trim_ascii_start(&self) -> &[u8] {
131132
let mut bytes = self;
@@ -144,18 +145,19 @@ impl [u8] {
144145
/// Returns a byte slice with trailing ASCII whitespace bytes removed.
145146
///
146147
/// 'Whitespace' refers to the definition used by
147-
/// `u8::is_ascii_whitespace`.
148+
/// [`u8::is_ascii_whitespace`].
149+
///
150+
/// [`u8::is_ascii_whitespace`]: u8::is_ascii_whitespace
148151
///
149152
/// # Examples
150153
///
151154
/// ```
152-
/// #![feature(byte_slice_trim_ascii)]
153-
///
154155
/// assert_eq!(b"\r hello world\n ".trim_ascii_end(), b"\r hello world");
155156
/// assert_eq!(b" ".trim_ascii_end(), b"");
156157
/// assert_eq!(b"".trim_ascii_end(), b"");
157158
/// ```
158-
#[unstable(feature = "byte_slice_trim_ascii", issue = "94035")]
159+
#[stable(feature = "byte_slice_trim_ascii", since = "CURRENT_RUSTC_VERSION")]
160+
#[rustc_const_stable(feature = "byte_slice_trim_ascii", since = "CURRENT_RUSTC_VERSION")]
159161
#[inline]
160162
pub const fn trim_ascii_end(&self) -> &[u8] {
161163
let mut bytes = self;
@@ -175,18 +177,19 @@ impl [u8] {
175177
/// removed.
176178
///
177179
/// 'Whitespace' refers to the definition used by
178-
/// `u8::is_ascii_whitespace`.
180+
/// [`u8::is_ascii_whitespace`].
181+
///
182+
/// [`u8::is_ascii_whitespace`]: u8::is_ascii_whitespace
179183
///
180184
/// # Examples
181185
///
182186
/// ```
183-
/// #![feature(byte_slice_trim_ascii)]
184-
///
185187
/// assert_eq!(b"\r hello world\n ".trim_ascii(), b"hello world");
186188
/// assert_eq!(b" ".trim_ascii(), b"");
187189
/// assert_eq!(b"".trim_ascii(), b"");
188190
/// ```
189-
#[unstable(feature = "byte_slice_trim_ascii", issue = "94035")]
191+
#[stable(feature = "byte_slice_trim_ascii", since = "CURRENT_RUSTC_VERSION")]
192+
#[rustc_const_stable(feature = "byte_slice_trim_ascii", since = "CURRENT_RUSTC_VERSION")]
190193
#[inline]
191194
pub const fn trim_ascii(&self) -> &[u8] {
192195
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)