Skip to main content

HofTrait

Trait HofTrait 

Source
pub trait HofTrait<R, V, Root, Value, MutRoot, MutValue, G, S>: KpTrait<R, V, Root, Value, MutRoot, MutValue, G, S>
where Root: Borrow<R>, Value: Borrow<V>, MutRoot: BorrowMut<R>, MutValue: BorrowMut<V>, G: Fn(Root) -> Option<Value>, S: Fn(MutRoot) -> Option<MutValue>,
{
Show 16 methods // Provided methods fn map<MappedValue, F>( &self, mapper: F, ) -> Kp<R, MappedValue, Root, MappedValue, MutRoot, MappedValue, impl Fn(Root) -> Option<MappedValue> + '_, impl Fn(MutRoot) -> Option<MappedValue> + '_> where F: Fn(&V) -> MappedValue + Copy + 'static, V: 'static, MappedValue: 'static { ... } fn filter<F>( &self, predicate: F, ) -> Kp<R, V, Root, Value, MutRoot, MutValue, impl Fn(Root) -> Option<Value> + '_, impl Fn(MutRoot) -> Option<MutValue> + '_> where F: Fn(&V) -> bool + Copy + 'static, V: 'static { ... } fn filter_map<MappedValue, F>( &self, mapper: F, ) -> Kp<R, MappedValue, Root, MappedValue, MutRoot, MappedValue, impl Fn(Root) -> Option<MappedValue> + '_, impl Fn(MutRoot) -> Option<MappedValue> + '_> where F: Fn(&V) -> Option<MappedValue> + Copy + 'static, V: 'static, MappedValue: 'static { ... } fn inspect<F>( &self, inspector: F, ) -> Kp<R, V, Root, Value, MutRoot, MutValue, impl Fn(Root) -> Option<Value> + '_, impl Fn(MutRoot) -> Option<MutValue> + '_> where F: Fn(&V) + Copy + 'static, V: 'static { ... } fn flat_map<I, Item, F>(&self, mapper: F) -> impl Fn(Root) -> Vec<Item> + '_ where F: Fn(&V) -> I + 'static, V: 'static, I: IntoIterator<Item = Item>, Item: 'static { ... } fn fold_value<Acc, F>( &self, init: Acc, folder: F, ) -> impl Fn(Root) -> Acc + '_ where F: Fn(Acc, &V) -> Acc + 'static, V: 'static, Acc: Copy + 'static { ... } fn any<F>(&self, predicate: F) -> impl Fn(Root) -> bool + '_ where F: Fn(&V) -> bool + 'static, V: 'static { ... } fn all<F>(&self, predicate: F) -> impl Fn(Root) -> bool + '_ where F: Fn(&V) -> bool + 'static, V: 'static { ... } fn count_items<F>(&self, counter: F) -> impl Fn(Root) -> Option<usize> + '_ where F: Fn(&V) -> usize + 'static, V: 'static { ... } fn find_in<Item, F>(&self, finder: F) -> impl Fn(Root) -> Option<Item> + '_ where F: Fn(&V) -> Option<Item> + 'static, V: 'static, Item: 'static { ... } fn take<Output, F>( &self, n: usize, taker: F, ) -> impl Fn(Root) -> Option<Output> + '_ where F: Fn(&V, usize) -> Output + 'static, V: 'static, Output: 'static { ... } fn skip<Output, F>( &self, n: usize, skipper: F, ) -> impl Fn(Root) -> Option<Output> + '_ where F: Fn(&V, usize) -> Output + 'static, V: 'static, Output: 'static { ... } fn partition_value<Output, F>( &self, partitioner: F, ) -> impl Fn(Root) -> Option<Output> + '_ where F: Fn(&V) -> Output + 'static, V: 'static, Output: 'static { ... } fn min_value<Item, F>( &self, min_fn: F, ) -> impl Fn(Root) -> Option<Item> + '_ where F: Fn(&V) -> Option<Item> + 'static, V: 'static, Item: 'static { ... } fn max_value<Item, F>( &self, max_fn: F, ) -> impl Fn(Root) -> Option<Item> + '_ where F: Fn(&V) -> Option<Item> + 'static, V: 'static, Item: 'static { ... } fn sum_value<Sum, F>(&self, sum_fn: F) -> impl Fn(Root) -> Option<Sum> + '_ where F: Fn(&V) -> Sum + 'static, V: 'static, Sum: 'static { ... }
}

Provided Methods§

Source

fn map<MappedValue, F>( &self, mapper: F, ) -> Kp<R, MappedValue, Root, MappedValue, MutRoot, MappedValue, impl Fn(Root) -> Option<MappedValue> + '_, impl Fn(MutRoot) -> Option<MappedValue> + '_>
where F: Fn(&V) -> MappedValue + Copy + 'static, V: 'static, MappedValue: 'static,

Map the value through a transformation function.

Source

fn filter<F>( &self, predicate: F, ) -> Kp<R, V, Root, Value, MutRoot, MutValue, impl Fn(Root) -> Option<Value> + '_, impl Fn(MutRoot) -> Option<MutValue> + '_>
where F: Fn(&V) -> bool + Copy + 'static, V: 'static,

Filter the value based on a predicate.

Source

fn filter_map<MappedValue, F>( &self, mapper: F, ) -> Kp<R, MappedValue, Root, MappedValue, MutRoot, MappedValue, impl Fn(Root) -> Option<MappedValue> + '_, impl Fn(MutRoot) -> Option<MappedValue> + '_>
where F: Fn(&V) -> Option<MappedValue> + Copy + 'static, V: 'static, MappedValue: 'static,

Map and flatten when mapper returns an Option.

Source

fn inspect<F>( &self, inspector: F, ) -> Kp<R, V, Root, Value, MutRoot, MutValue, impl Fn(Root) -> Option<Value> + '_, impl Fn(MutRoot) -> Option<MutValue> + '_>
where F: Fn(&V) + Copy + 'static, V: 'static,

Apply a function for its side effects and return the value.

Source

fn flat_map<I, Item, F>(&self, mapper: F) -> impl Fn(Root) -> Vec<Item> + '_
where F: Fn(&V) -> I + 'static, V: 'static, I: IntoIterator<Item = Item>, Item: 'static,

Flat map - maps to an iterator and flattens.

Source

fn fold_value<Acc, F>(&self, init: Acc, folder: F) -> impl Fn(Root) -> Acc + '_
where F: Fn(Acc, &V) -> Acc + 'static, V: 'static, Acc: Copy + 'static,

Fold/reduce the value using an accumulator function.

Source

fn any<F>(&self, predicate: F) -> impl Fn(Root) -> bool + '_
where F: Fn(&V) -> bool + 'static, V: 'static,

Check if any element satisfies a predicate.

Source

fn all<F>(&self, predicate: F) -> impl Fn(Root) -> bool + '_
where F: Fn(&V) -> bool + 'static, V: 'static,

Check if all elements satisfy a predicate.

Source

fn count_items<F>(&self, counter: F) -> impl Fn(Root) -> Option<usize> + '_
where F: Fn(&V) -> usize + 'static, V: 'static,

Count elements in a collection value.

Source

fn find_in<Item, F>(&self, finder: F) -> impl Fn(Root) -> Option<Item> + '_
where F: Fn(&V) -> Option<Item> + 'static, V: 'static, Item: 'static,

Find first element matching predicate in a collection value.

Source

fn take<Output, F>( &self, n: usize, taker: F, ) -> impl Fn(Root) -> Option<Output> + '_
where F: Fn(&V, usize) -> Output + 'static, V: 'static, Output: 'static,

Take first N elements from a collection value.

Source

fn skip<Output, F>( &self, n: usize, skipper: F, ) -> impl Fn(Root) -> Option<Output> + '_
where F: Fn(&V, usize) -> Output + 'static, V: 'static, Output: 'static,

Skip first N elements from a collection value.

Source

fn partition_value<Output, F>( &self, partitioner: F, ) -> impl Fn(Root) -> Option<Output> + '_
where F: Fn(&V) -> Output + 'static, V: 'static, Output: 'static,

Partition a collection value into two groups based on predicate.

Source

fn min_value<Item, F>(&self, min_fn: F) -> impl Fn(Root) -> Option<Item> + '_
where F: Fn(&V) -> Option<Item> + 'static, V: 'static, Item: 'static,

Get min value from a collection.

Source

fn max_value<Item, F>(&self, max_fn: F) -> impl Fn(Root) -> Option<Item> + '_
where F: Fn(&V) -> Option<Item> + 'static, V: 'static, Item: 'static,

Get max value from a collection.

Source

fn sum_value<Sum, F>(&self, sum_fn: F) -> impl Fn(Root) -> Option<Sum> + '_
where F: Fn(&V) -> Sum + 'static, V: 'static, Sum: 'static,

Sum numeric values in a collection.

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.

Implementors§

Source§

impl<R, V, Root, Value, MutRoot, MutValue, G, S> HofTrait<R, V, Root, Value, MutRoot, MutValue, G, S> for Kp<R, V, Root, Value, MutRoot, MutValue, G, S>
where Root: Borrow<R>, Value: Borrow<V>, MutRoot: BorrowMut<R>, MutValue: BorrowMut<V>, G: Fn(Root) -> Option<Value>, S: Fn(MutRoot) -> Option<MutValue>,