KeyPathsCollectionExt

Trait KeyPathsCollectionExt 

Source
pub trait KeyPathsCollectionExt<T> {
Show 13 methods // Required methods fn collect_keypath<V>( &self, keypath: KeyPaths<T, V>, ) -> KeyPathResult<Vec<V>> where V: Clone; fn partition_by_keypath<V, F>( &self, keypath: KeyPaths<T, V>, predicate: F, ) -> KeyPathResult<(Vec<T>, Vec<T>)> where T: Clone, F: Fn(&V) -> bool; fn group_by_keypath<V, F>( &self, keypath: KeyPaths<T, V>, f: F, ) -> KeyPathResult<HashMap<V, Vec<T>>> where V: Hash + Eq + Clone, T: Clone, F: Fn(&V) -> V; fn sort_by_keypath<V, F>( &mut self, keypath: KeyPaths<T, V>, compare: F, ) -> KeyPathResult<()> where F: Fn(&V, &V) -> Ordering; fn find_by_keypath<V, F>( &self, keypath: KeyPaths<T, V>, predicate: F, ) -> KeyPathResult<Option<&T>> where F: Fn(&V) -> bool; fn any_by_keypath<V, F>( &self, keypath: KeyPaths<T, V>, predicate: F, ) -> KeyPathResult<bool> where F: Fn(&V) -> bool; fn all_by_keypath<V, F>( &self, keypath: KeyPaths<T, V>, predicate: F, ) -> KeyPathResult<bool> where F: Fn(&V) -> bool; fn count_by_keypath<V, F>( &self, keypath: KeyPaths<T, V>, predicate: F, ) -> KeyPathResult<usize> where F: Fn(&V) -> bool; fn unique_by_keypath<V>( &self, keypath: KeyPaths<T, V>, ) -> KeyPathResult<HashSet<V>> where V: Hash + Eq + Clone; fn distinct_by_keypath<V>( &self, keypath: KeyPaths<T, V>, ) -> KeyPathResult<HashMap<V, usize>> where V: Hash + Eq + Clone; fn zip_with_keypath<U, V1, V2, F, R>( &self, other: &[U], keypath1: KeyPaths<T, V1>, keypath2: KeyPaths<U, V2>, f: F, ) -> KeyPathResult<Vec<R>> where F: Fn(&V1, &V2) -> R; fn window_by_keypath<V, F, R>( &self, keypath: KeyPaths<T, V>, window_size: usize, f: F, ) -> KeyPathResult<Vec<R>> where V: Clone, F: Fn(&[V]) -> R; fn rolling_by_keypath<V, F, R>( &self, keypath: KeyPaths<T, V>, window_size: usize, f: F, ) -> KeyPathResult<Vec<R>> where V: Clone, F: Fn(&[V]) -> R;
}
Expand description

Extension trait for collections with keypath operations

Required Methods§

Source

fn collect_keypath<V>(&self, keypath: KeyPaths<T, V>) -> KeyPathResult<Vec<V>>
where V: Clone,

Extract values from keypaths into collections

Source

fn partition_by_keypath<V, F>( &self, keypath: KeyPaths<T, V>, predicate: F, ) -> KeyPathResult<(Vec<T>, Vec<T>)>
where T: Clone, F: Fn(&V) -> bool,

Partition elements by keypath predicate

Source

fn group_by_keypath<V, F>( &self, keypath: KeyPaths<T, V>, f: F, ) -> KeyPathResult<HashMap<V, Vec<T>>>
where V: Hash + Eq + Clone, T: Clone, F: Fn(&V) -> V,

Group elements by keypath values

Source

fn sort_by_keypath<V, F>( &mut self, keypath: KeyPaths<T, V>, compare: F, ) -> KeyPathResult<()>
where F: Fn(&V, &V) -> Ordering,

Sort elements by keypath values

Source

fn find_by_keypath<V, F>( &self, keypath: KeyPaths<T, V>, predicate: F, ) -> KeyPathResult<Option<&T>>
where F: Fn(&V) -> bool,

Find elements matching keypath conditions

Source

fn any_by_keypath<V, F>( &self, keypath: KeyPaths<T, V>, predicate: F, ) -> KeyPathResult<bool>
where F: Fn(&V) -> bool,

Check if any element matches keypath condition

Source

fn all_by_keypath<V, F>( &self, keypath: KeyPaths<T, V>, predicate: F, ) -> KeyPathResult<bool>
where F: Fn(&V) -> bool,

Check if all elements match keypath condition

Source

fn count_by_keypath<V, F>( &self, keypath: KeyPaths<T, V>, predicate: F, ) -> KeyPathResult<usize>
where F: Fn(&V) -> bool,

Count elements matching keypath condition

Source

fn unique_by_keypath<V>( &self, keypath: KeyPaths<T, V>, ) -> KeyPathResult<HashSet<V>>
where V: Hash + Eq + Clone,

Get unique values from keypath

Source

fn distinct_by_keypath<V>( &self, keypath: KeyPaths<T, V>, ) -> KeyPathResult<HashMap<V, usize>>
where V: Hash + Eq + Clone,

Get distinct values from keypath with counts

Source

fn zip_with_keypath<U, V1, V2, F, R>( &self, other: &[U], keypath1: KeyPaths<T, V1>, keypath2: KeyPaths<U, V2>, f: F, ) -> KeyPathResult<Vec<R>>
where F: Fn(&V1, &V2) -> R,

Zip with another collection using keypath values

Source

fn window_by_keypath<V, F, R>( &self, keypath: KeyPaths<T, V>, window_size: usize, f: F, ) -> KeyPathResult<Vec<R>>
where V: Clone, F: Fn(&[V]) -> R,

Window operations over keypath values

Source

fn rolling_by_keypath<V, F, R>( &self, keypath: KeyPaths<T, V>, window_size: usize, f: F, ) -> KeyPathResult<Vec<R>>
where V: Clone, F: Fn(&[V]) -> R,

Rolling operations over keypath values

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: KeyPathsOperable> KeyPathsCollectionExt<T> for Vec<T>

Source§

fn collect_keypath<V>(&self, keypath: KeyPaths<T, V>) -> KeyPathResult<Vec<V>>
where V: Clone,

Source§

fn partition_by_keypath<V, F>( &self, keypath: KeyPaths<T, V>, predicate: F, ) -> KeyPathResult<(Vec<T>, Vec<T>)>
where T: Clone, F: Fn(&V) -> bool,

Source§

fn group_by_keypath<V, F>( &self, keypath: KeyPaths<T, V>, f: F, ) -> KeyPathResult<HashMap<V, Vec<T>>>
where V: Hash + Eq + Clone, T: Clone, F: Fn(&V) -> V,

Source§

fn sort_by_keypath<V, F>( &mut self, keypath: KeyPaths<T, V>, compare: F, ) -> KeyPathResult<()>
where F: Fn(&V, &V) -> Ordering,

Source§

fn find_by_keypath<V, F>( &self, keypath: KeyPaths<T, V>, predicate: F, ) -> KeyPathResult<Option<&T>>
where F: Fn(&V) -> bool,

Source§

fn any_by_keypath<V, F>( &self, keypath: KeyPaths<T, V>, predicate: F, ) -> KeyPathResult<bool>
where F: Fn(&V) -> bool,

Source§

fn all_by_keypath<V, F>( &self, keypath: KeyPaths<T, V>, predicate: F, ) -> KeyPathResult<bool>
where F: Fn(&V) -> bool,

Source§

fn count_by_keypath<V, F>( &self, keypath: KeyPaths<T, V>, predicate: F, ) -> KeyPathResult<usize>
where F: Fn(&V) -> bool,

Source§

fn unique_by_keypath<V>( &self, keypath: KeyPaths<T, V>, ) -> KeyPathResult<HashSet<V>>
where V: Hash + Eq + Clone,

Source§

fn distinct_by_keypath<V>( &self, keypath: KeyPaths<T, V>, ) -> KeyPathResult<HashMap<V, usize>>
where V: Hash + Eq + Clone,

Source§

fn zip_with_keypath<U, V1, V2, F, R>( &self, other: &[U], keypath1: KeyPaths<T, V1>, keypath2: KeyPaths<U, V2>, f: F, ) -> KeyPathResult<Vec<R>>
where U: KeyPathsOperable, F: Fn(&V1, &V2) -> R,

Source§

fn window_by_keypath<V, F, R>( &self, keypath: KeyPaths<T, V>, window_size: usize, f: F, ) -> KeyPathResult<Vec<R>>
where V: Clone, F: Fn(&[V]) -> R,

Source§

fn rolling_by_keypath<V, F, R>( &self, keypath: KeyPaths<T, V>, window_size: usize, f: F, ) -> KeyPathResult<Vec<R>>
where V: Clone, F: Fn(&[V]) -> R,

Implementors§