Skip to content

Commit 3bcf697

Browse files
authored
Rollup merge of #72466 - lzutao:stabilize_str-strip, r=dtolnay
Stabilize str_strip feature This PR stabilizes these APIs: ```rust impl str { /// Returns a string slice with the prefix removed. /// /// If the string starts with the pattern `prefix`, `Some` is returned with the substring where /// the prefix is removed. Unlike `trim_start_matches`, this method removes the prefix exactly /// once. pub fn strip_prefix<'a, P: Pattern<'a>>(&'a self, prefix: P) -> Option<&'a str>; /// Returns a string slice with the suffix removed. /// /// If the string ends with the pattern `suffix`, `Some` is returned with the substring where /// the suffix is removed. Unlike `trim_end_matches`, this method removes the suffix exactly /// once. pub fn strip_suffix<'a, P>(&'a self, suffix: P) -> Option<&'a str> where P: Pattern<'a>, <P as Pattern<'a>>::Searcher: ReverseSearcher<'a>; } ``` Closes #67302
2 parents b18c55b + 2df69ba commit 3bcf697

File tree

3 files changed

+2
-7
lines changed

3 files changed

+2
-7
lines changed

src/libcore/str/mod.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -4052,15 +4052,13 @@ impl str {
40524052
/// # Examples
40534053
///
40544054
/// ```
4055-
/// #![feature(str_strip)]
4056-
///
40574055
/// assert_eq!("foo:bar".strip_prefix("foo:"), Some("bar"));
40584056
/// assert_eq!("foo:bar".strip_prefix("bar"), None);
40594057
/// assert_eq!("foofoo".strip_prefix("foo"), Some("foo"));
40604058
/// ```
40614059
#[must_use = "this returns the remaining substring as a new slice, \
40624060
without modifying the original"]
4063-
#[unstable(feature = "str_strip", reason = "newly added", issue = "67302")]
4061+
#[stable(feature = "str_strip", since = "1.45.0")]
40644062
pub fn strip_prefix<'a, P: Pattern<'a>>(&'a self, prefix: P) -> Option<&'a str> {
40654063
prefix.strip_prefix_of(self)
40664064
}
@@ -4082,14 +4080,13 @@ impl str {
40824080
/// # Examples
40834081
///
40844082
/// ```
4085-
/// #![feature(str_strip)]
40864083
/// assert_eq!("bar:foo".strip_suffix(":foo"), Some("bar"));
40874084
/// assert_eq!("bar:foo".strip_suffix("bar"), None);
40884085
/// assert_eq!("foofoo".strip_suffix("foo"), Some("foo"));
40894086
/// ```
40904087
#[must_use = "this returns the remaining substring as a new slice, \
40914088
without modifying the original"]
4092-
#[unstable(feature = "str_strip", reason = "newly added", issue = "67302")]
4089+
#[stable(feature = "str_strip", since = "1.45.0")]
40934090
pub fn strip_suffix<'a, P>(&'a self, suffix: P) -> Option<&'a str>
40944091
where
40954092
P: Pattern<'a>,

src/librustc_trait_selection/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#![feature(in_band_lifetimes)]
1717
#![feature(crate_visibility_modifier)]
1818
#![feature(or_patterns)]
19-
#![feature(str_strip)]
2019
#![feature(option_zip)]
2120
#![recursion_limit = "512"] // For rustdoc
2221

src/tools/clippy/src/driver.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#![cfg_attr(feature = "deny-warnings", deny(warnings))]
22
#![feature(rustc_private)]
3-
#![feature(str_strip)]
43

54
// FIXME: switch to something more ergonomic here, once available.
65
// (Currently there is no way to opt into sysroot crates without `extern crate`.)

0 commit comments

Comments
 (0)