string_retain -

# `string_retain`

The tracking issue for this feature is: #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.

    # #![allow(unused_variables)]
    #![feature(string_retain)]

    #fn main() {
    let mut s = String::from("f_o_ob_ar");

    s.retain(|c| c != '_');

    assert_eq!(s, "foobar");
    #}