Rollup merge of #49243 - murarth:stabilize-retain, r=BurntSushi
Stabilize method `String::retain` Closes #43874
This commit is contained in:
@@ -1,23 +0,0 @@
|
|||||||
# `string_retain`
|
|
||||||
|
|
||||||
The tracking issue for this feature is: [#43874]
|
|
||||||
|
|
||||||
[#43874]: https://github.com/rust-lang/rust/issues/43874
|
|
||||||
|
|
||||||
------------------------
|
|
||||||
|
|
||||||
Retains only the characters specified by the predicate.
|
|
||||||
|
|
||||||
In other words, remove all characters `c` such that `f(c)` returns `false`.
|
|
||||||
This method operates in place and preserves the order of the retained
|
|
||||||
characters.
|
|
||||||
|
|
||||||
```rust
|
|
||||||
#![feature(string_retain)]
|
|
||||||
|
|
||||||
let mut s = String::from("f_o_ob_ar");
|
|
||||||
|
|
||||||
s.retain(|c| c != '_');
|
|
||||||
|
|
||||||
assert_eq!(s, "foobar");
|
|
||||||
```
|
|
||||||
@@ -1177,8 +1177,6 @@ impl String {
|
|||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// #![feature(string_retain)]
|
|
||||||
///
|
|
||||||
/// let mut s = String::from("f_o_ob_ar");
|
/// let mut s = String::from("f_o_ob_ar");
|
||||||
///
|
///
|
||||||
/// s.retain(|c| c != '_');
|
/// s.retain(|c| c != '_');
|
||||||
@@ -1186,7 +1184,7 @@ impl String {
|
|||||||
/// assert_eq!(s, "foobar");
|
/// assert_eq!(s, "foobar");
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
#[unstable(feature = "string_retain", issue = "43874")]
|
#[stable(feature = "string_retain", since = "1.26.0")]
|
||||||
pub fn retain<F>(&mut self, mut f: F)
|
pub fn retain<F>(&mut self, mut f: F)
|
||||||
where F: FnMut(char) -> bool
|
where F: FnMut(char) -> bool
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user