KeyPathsCollection

Trait KeyPathsCollection 

Source
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§

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 + KeyPathsOperable, F: Fn(&V) -> V,

Group elements by keypath values

Source

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,

Partition elements by keypath predicate

Source

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

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.

Implementations on Foreign Types§

Source§

impl<T> KeyPathsCollection<T> for Vec<T>

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 + KeyPathsOperable, F: Fn(&V) -> V,

Source§

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,

Source§

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

Implementors§