-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Open
Labels
T-libs-apiRelevant to the library API team, which will review and decide on the RFC.Relevant to the library API team, which will review and decide on the RFC.
Description
/// Trims this slice from the left.
fn trim_left_matches<F: Fn(T) -> bool>(&self, f: F) -> &[T] {
let mut res = self;
while res.len() > 0 && f(res[0]) {
res = res[1..];
}
res
}
/// Trims this slice from the right.
fn trim_right_matches<F: Fn(T) -> bool>(&self, f: F) -> &[T] {
let mut res = self;
while res.len() > 0 && f(res[res.len()-1]) {
res = res[..(res.len()-1)];
}
res
}
(and so on)
basically turns &["", "", "", "foo", ""]
into &["foo", ""]
, &["", "foo", "", "", ""]
into &["", "foo"]
, etc, depending on what you call.
ebkalderon, Aloso, lpotthast and rodrigocfdgregkatz
Metadata
Metadata
Assignees
Labels
T-libs-apiRelevant to the library API team, which will review and decide on the RFC.Relevant to the library API team, which will review and decide on the RFC.