typst_utils

Trait SliceExt

source
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;
}
Expand description

Extra methods for [T].

Required Methods§

source

fn trim_start_matches<F>(&self, f: F) -> &[T]
where F: FnMut(&T) -> bool,

Returns a slice with all matching elements from the start of the slice removed.

source

fn trim_end_matches<F>(&self, f: F) -> &[T]
where F: FnMut(&T) -> bool,

Returns a slice with all matching elements from the end of the slice removed.

source

fn group_by_key<K, F>(&self, f: F) -> GroupByKey<'_, T, F>
where F: FnMut(&T) -> K, K: PartialEq,

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.

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.

Implementations on Foreign Types§

source§

impl<T> SliceExt<T> for [T]

source§

fn trim_start_matches<F>(&self, f: F) -> &[T]
where F: FnMut(&T) -> bool,

source§

fn trim_end_matches<F>(&self, f: F) -> &[T]
where F: FnMut(&T) -> bool,

source§

fn group_by_key<K, F>(&self, f: F) -> GroupByKey<'_, T, F>

Implementors§