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§
Sourcefn collect_keypath<V>(&self, keypath: KeyPaths<T, V>) -> KeyPathResult<Vec<V>>where
V: Clone,
fn collect_keypath<V>(&self, keypath: KeyPaths<T, V>) -> KeyPathResult<Vec<V>>where
V: Clone,
Extract values from keypaths into collections
Sourcefn partition_by_keypath<V, F>(
&self,
keypath: KeyPaths<T, V>,
predicate: F,
) -> KeyPathResult<(Vec<T>, Vec<T>)>
fn partition_by_keypath<V, F>( &self, keypath: KeyPaths<T, V>, predicate: F, ) -> KeyPathResult<(Vec<T>, Vec<T>)>
Partition elements by keypath predicate
Sourcefn group_by_keypath<V, F>(
&self,
keypath: KeyPaths<T, V>,
f: F,
) -> KeyPathResult<HashMap<V, Vec<T>>>
fn group_by_keypath<V, F>( &self, keypath: KeyPaths<T, V>, f: F, ) -> KeyPathResult<HashMap<V, Vec<T>>>
Group elements by keypath values
Sourcefn sort_by_keypath<V, F>(
&mut self,
keypath: KeyPaths<T, V>,
compare: F,
) -> KeyPathResult<()>
fn sort_by_keypath<V, F>( &mut self, keypath: KeyPaths<T, V>, compare: F, ) -> KeyPathResult<()>
Sort elements by keypath values
Sourcefn find_by_keypath<V, F>(
&self,
keypath: KeyPaths<T, V>,
predicate: F,
) -> KeyPathResult<Option<&T>>
fn find_by_keypath<V, F>( &self, keypath: KeyPaths<T, V>, predicate: F, ) -> KeyPathResult<Option<&T>>
Find elements matching keypath conditions
Sourcefn any_by_keypath<V, F>(
&self,
keypath: KeyPaths<T, V>,
predicate: F,
) -> KeyPathResult<bool>
fn any_by_keypath<V, F>( &self, keypath: KeyPaths<T, V>, predicate: F, ) -> KeyPathResult<bool>
Check if any element matches keypath condition
Sourcefn all_by_keypath<V, F>(
&self,
keypath: KeyPaths<T, V>,
predicate: F,
) -> KeyPathResult<bool>
fn all_by_keypath<V, F>( &self, keypath: KeyPaths<T, V>, predicate: F, ) -> KeyPathResult<bool>
Check if all elements match keypath condition
Sourcefn count_by_keypath<V, F>(
&self,
keypath: KeyPaths<T, V>,
predicate: F,
) -> KeyPathResult<usize>
fn count_by_keypath<V, F>( &self, keypath: KeyPaths<T, V>, predicate: F, ) -> KeyPathResult<usize>
Count elements matching keypath condition
Sourcefn unique_by_keypath<V>(
&self,
keypath: KeyPaths<T, V>,
) -> KeyPathResult<HashSet<V>>
fn unique_by_keypath<V>( &self, keypath: KeyPaths<T, V>, ) -> KeyPathResult<HashSet<V>>
Get unique values from keypath
Sourcefn distinct_by_keypath<V>(
&self,
keypath: KeyPaths<T, V>,
) -> KeyPathResult<HashMap<V, usize>>
fn distinct_by_keypath<V>( &self, keypath: KeyPaths<T, V>, ) -> KeyPathResult<HashMap<V, usize>>
Get distinct values from keypath with counts
Sourcefn zip_with_keypath<U, V1, V2, F, R>(
&self,
other: &[U],
keypath1: KeyPaths<T, V1>,
keypath2: KeyPaths<U, V2>,
f: F,
) -> KeyPathResult<Vec<R>>
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>>
Zip with another collection using keypath values
Sourcefn window_by_keypath<V, F, R>(
&self,
keypath: KeyPaths<T, V>,
window_size: usize,
f: F,
) -> KeyPathResult<Vec<R>>
fn window_by_keypath<V, F, R>( &self, keypath: KeyPaths<T, V>, window_size: usize, f: F, ) -> KeyPathResult<Vec<R>>
Window operations over keypath values
Sourcefn rolling_by_keypath<V, F, R>(
&self,
keypath: KeyPaths<T, V>,
window_size: usize,
f: F,
) -> KeyPathResult<Vec<R>>
fn rolling_by_keypath<V, F, R>( &self, keypath: KeyPaths<T, V>, window_size: usize, f: F, ) -> KeyPathResult<Vec<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.