pub trait SliceExt<T> {
// Required methods
fn trim_start_matches<F>(&self, f: F) -> &[T]
where F: FnMut(&T) -> bool;
fn trim_end_matches<F>(&self, f: F) -> &[T]
where F: FnMut(&T) -> bool;
fn group_by_key<K, F>(&self, f: F) -> GroupByKey<'_, T, F> ⓘ
where F: FnMut(&T) -> K,
K: PartialEq;
fn split_prefix_suffix<F>(&self, f: F) -> (usize, usize)
where F: FnMut(&T) -> bool;
}
Expand description
Extra methods for [T]
.
Required Methods§
Sourcefn trim_start_matches<F>(&self, f: F) -> &[T]
fn trim_start_matches<F>(&self, f: F) -> &[T]
Returns a slice with all matching elements from the start of the slice removed.
Sourcefn trim_end_matches<F>(&self, f: F) -> &[T]
fn trim_end_matches<F>(&self, f: F) -> &[T]
Returns a slice with all matching elements from the end of the slice removed.
Sourcefn group_by_key<K, F>(&self, f: F) -> GroupByKey<'_, T, F> ⓘ
fn group_by_key<K, F>(&self, f: F) -> GroupByKey<'_, T, F> ⓘ
Split a slice into consecutive runs with the same key and yield for each such run the key and the slice of elements with that key.
Sourcefn split_prefix_suffix<F>(&self, f: F) -> (usize, usize)
fn split_prefix_suffix<F>(&self, f: F) -> (usize, usize)
Computes two indices which split a slice into three parts.
- A prefix which matches
f
- An inner portion
- A suffix which matches
f
and does not overlap with the prefix
If all elements match f
, the prefix becomes self
and the suffix
will be empty.
Returns the indices at which the inner portion and the suffix start.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.