pub trait KeyPathsCollection<T> {
// Required methods
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 + KeyPathsOperable,
F: Fn(&V) -> V;
fn partition_by_keypath<V, F>(
&self,
keypath: KeyPaths<T, V>,
predicate: F,
) -> KeyPathResult<(Vec<T>, Vec<T>)>
where T: Clone + KeyPathsOperable,
F: Fn(&V) -> bool;
fn sort_by_keypath<V, F>(
&mut self,
keypath: KeyPaths<T, V>,
compare: F,
) -> KeyPathResult<()>
where T: KeyPathsOperable,
F: Fn(&V, &V) -> Ordering;
}Expand description
Trait for collections that support keypath operations
Required Methods§
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 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 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
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.