pub struct CountFold<L> { /* private fields */ }Expand description
A zero-allocation count fold.
Implementations§
Trait Implementations§
Source§impl<L> Fold<L, usize> for CountFold<L>
impl<L> Fold<L, usize> for CountFold<L>
Source§fn initial(&self, _context: &FoldContext) -> usize
fn initial(&self, _context: &FoldContext) -> usize
Get the initial state before any entries are processed.
Source§fn step(&self, state: usize, _entry: &L, _context: &FoldContext) -> usize
fn step(&self, state: usize, _entry: &L, _context: &FoldContext) -> usize
Process a single entry and return the new state. Read more
Source§fn finalize(&self, state: S, _context: &FoldContext) -> S
fn finalize(&self, state: S, _context: &FoldContext) -> S
Finalize the state after all entries are processed. Read more
Source§fn derive<'a, I>(&self, entries: I, context: &FoldContext) -> FoldOutcome<S>
fn derive<'a, I>(&self, entries: I, context: &FoldContext) -> FoldOutcome<S>
Derive state from an iterator of entries. Read more
Source§fn derive_filtered<'a, I, F>(
&self,
entries: I,
context: &FoldContext,
filter: F,
) -> FoldOutcome<S>
fn derive_filtered<'a, I, F>( &self, entries: I, context: &FoldContext, filter: F, ) -> FoldOutcome<S>
Derive state with a filter.
Source§impl<L> TryFold<L, usize> for CountFold<L>
impl<L> TryFold<L, usize> for CountFold<L>
Source§fn try_step(
&self,
state: usize,
entry: &L,
context: &FoldContext,
) -> Result<usize, FoldFailure>
fn try_step( &self, state: usize, entry: &L, context: &FoldContext, ) -> Result<usize, FoldFailure>
Process a single entry and return an error instead of panicking.
impl<L: Copy> Copy for CountFold<L>
Auto Trait Implementations§
impl<L> Freeze for CountFold<L>
impl<L> RefUnwindSafe for CountFold<L>
impl<L> Send for CountFold<L>
impl<L> Sync for CountFold<L>
impl<L> Unpin for CountFold<L>
impl<L> UnsafeUnpin for CountFold<L>
impl<L> UnwindSafe for CountFold<L>
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