ClosureFold

Struct ClosureFold 

Source
pub struct ClosureFold<M, K, V, R, FAdd, FRemove, FUpdate, FInitial> { /* private fields */ }
Expand description

An implementation of UnorderedFold using a builder pattern and closures.

Implementations§

Source§

impl ClosureFold<(), (), (), (), (), (), (), ()>

Source

pub fn new<M, K, V, R>() -> ClosureFold<M, K, V, R, (), (), fn(R, &K, &V, &V) -> R, fn(R, &M) -> R>

Source

pub fn new_add_remove<M, K, V, R, FAdd, FRemove>( add: FAdd, remove: FRemove, ) -> ClosureFold<M, K, V, R, FAdd, FRemove, fn(R, &K, &V, &V) -> R, fn(R, &M) -> R>
where FAdd: for<'a> FnMut(R, &'a K, &'a V) -> R + 'static + NotObserver, FRemove: for<'a> FnMut(R, &'a K, &'a V) -> R + 'static + NotObserver,

Source§

impl<M, K, V, R, FAdd_, FRemove_, FUpdate_, FInitial_> ClosureFold<M, K, V, R, FAdd_, FRemove_, FUpdate_, FInitial_>

Source

pub fn add<FAdd>( self, add: FAdd, ) -> ClosureFold<M, K, V, R, FAdd, FRemove_, FUpdate_, FInitial_>
where FAdd: for<'a> FnMut(R, &'a K, &'a V) -> R + 'static + NotObserver,

Source

pub fn remove<FRemove>( self, remove: FRemove, ) -> ClosureFold<M, K, V, R, FAdd_, FRemove, FUpdate_, FInitial_>
where FRemove: for<'a> FnMut(R, &'a K, &'a V) -> R + 'static + NotObserver,

Source

pub fn update<FUpdate>( self, update: FUpdate, ) -> ClosureFold<M, K, V, R, FAdd_, FRemove_, FUpdate, FInitial_>
where FUpdate: for<'a> FnMut(R, &'a K, &'a V, &'a V) -> R + 'static + NotObserver,

Source

pub fn initial<FInitial>( self, initial: FInitial, ) -> ClosureFold<M, K, V, R, FAdd_, FRemove_, FUpdate_, FInitial>
where FInitial: for<'a> FnMut(R, &'a M) -> R + 'static + NotObserver,

Source

pub fn revert_to_init_when_empty( self, revert_to_init_when_empty: bool, ) -> ClosureFold<M, K, V, R, FAdd_, FRemove_, FUpdate_, FInitial_>

Trait Implementations§

Source§

impl<M, K, V, R, FAdd, FRemove, FUpdate, FInitial> UnorderedFold<M, K, V, R> for ClosureFold<M, K, V, R, FAdd, FRemove, FUpdate, FInitial>
where M: SymmetricFoldMap<K, V>, K: Value + Ord, V: Value, R: Value, FAdd: for<'a> FnMut(R, &'a K, &'a V) -> R + 'static + NotObserver, FRemove: for<'a> FnMut(R, &'a K, &'a V) -> R + 'static + NotObserver, FUpdate: for<'a> FnMut(R, &'a K, &'a V, &'a V) -> R + 'static + NotObserver, FInitial: for<'a> FnMut(R, &'a M) -> R + 'static + NotObserver,

Source§

fn add(&mut self, acc: R, key: &K, value: &V) -> R

How to add a key/value pair to the fold value Read more
Source§

fn remove(&mut self, acc: R, key: &K, value: &V) -> R

How to remove a key/value pair from the fold value Read more
Source§

fn update(&mut self, acc: R, key: &K, old: &V, new: &V) -> R

Default implementation is self.add(self.remove(acc, key, old), key, new)
Source§

fn revert_to_init_when_empty(&self) -> bool

If we have emptied the map, can we just reset to the initial value? Or do we have to call remove() on everything that was removed?
Source§

fn initial_fold(&mut self, init: R, input: &M) -> R

Optimize the initial fold

Auto Trait Implementations§

§

impl<M, K, V, R, FAdd, FRemove, FUpdate, FInitial> Freeze for ClosureFold<M, K, V, R, FAdd, FRemove, FUpdate, FInitial>
where FAdd: Freeze, FRemove: Freeze, FUpdate: Freeze, FInitial: Freeze,

§

impl<M, K, V, R, FAdd, FRemove, FUpdate, FInitial> RefUnwindSafe for ClosureFold<M, K, V, R, FAdd, FRemove, FUpdate, FInitial>

§

impl<M, K, V, R, FAdd, FRemove, FUpdate, FInitial> Send for ClosureFold<M, K, V, R, FAdd, FRemove, FUpdate, FInitial>
where FAdd: Send, FRemove: Send, FUpdate: Send, FInitial: Send, M: Send, K: Send, V: Send, R: Send,

§

impl<M, K, V, R, FAdd, FRemove, FUpdate, FInitial> Sync for ClosureFold<M, K, V, R, FAdd, FRemove, FUpdate, FInitial>
where FAdd: Sync, FRemove: Sync, FUpdate: Sync, FInitial: Sync, M: Sync, K: Sync, V: Sync, R: Sync,

§

impl<M, K, V, R, FAdd, FRemove, FUpdate, FInitial> Unpin for ClosureFold<M, K, V, R, FAdd, FRemove, FUpdate, FInitial>
where FAdd: Unpin, FRemove: Unpin, FUpdate: Unpin, FInitial: Unpin, M: Unpin, K: Unpin, V: Unpin, R: Unpin,

§

impl<M, K, V, R, FAdd, FRemove, FUpdate, FInitial> UnwindSafe for ClosureFold<M, K, V, R, FAdd, FRemove, FUpdate, FInitial>
where FAdd: UnwindSafe, FRemove: UnwindSafe, FUpdate: UnwindSafe, FInitial: UnwindSafe, M: UnwindSafe, K: UnwindSafe, V: UnwindSafe, R: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> NotObserver for T
where T: ?Sized,