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<(), (), (), (), (), (), (), ()>
impl ClosureFold<(), (), (), (), (), (), (), ()>
pub fn new<M, K, V, R>() -> ClosureFold<M, K, V, R, (), (), fn(R, &K, &V, &V) -> R, fn(R, &M) -> R>
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_>
impl<M, K, V, R, FAdd_, FRemove_, FUpdate_, FInitial_> ClosureFold<M, K, V, R, FAdd_, FRemove_, FUpdate_, FInitial_>
pub fn add<FAdd>( self, add: FAdd, ) -> ClosureFold<M, K, V, R, FAdd, FRemove_, FUpdate_, FInitial_>
pub fn remove<FRemove>( self, remove: FRemove, ) -> ClosureFold<M, K, V, R, FAdd_, FRemove, FUpdate_, FInitial_>
pub fn update<FUpdate>( self, update: FUpdate, ) -> ClosureFold<M, K, V, R, FAdd_, FRemove_, FUpdate, FInitial_>
pub fn initial<FInitial>( self, initial: FInitial, ) -> ClosureFold<M, K, V, R, FAdd_, FRemove_, FUpdate_, FInitial>
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,
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
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
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
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
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
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>
impl<M, K, V, R, FAdd, FRemove, FUpdate, FInitial> RefUnwindSafe for ClosureFold<M, K, V, R, FAdd, FRemove, FUpdate, FInitial>where
FAdd: RefUnwindSafe,
FRemove: RefUnwindSafe,
FUpdate: RefUnwindSafe,
FInitial: RefUnwindSafe,
M: RefUnwindSafe,
K: RefUnwindSafe,
V: RefUnwindSafe,
R: RefUnwindSafe,
impl<M, K, V, R, FAdd, FRemove, FUpdate, FInitial> Send for ClosureFold<M, K, V, R, FAdd, FRemove, FUpdate, FInitial>
impl<M, K, V, R, FAdd, FRemove, FUpdate, FInitial> Sync for ClosureFold<M, K, V, R, FAdd, FRemove, FUpdate, FInitial>
impl<M, K, V, R, FAdd, FRemove, FUpdate, FInitial> Unpin for ClosureFold<M, K, V, R, FAdd, FRemove, FUpdate, FInitial>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more