pub struct Folded<Brand>(pub PhantomData<Brand>);Expand description
A wrapper struct for the folded constructor.
Tuple Fields§
§0: PhantomData<Brand>Trait Implementations§
Source§impl<'a, I, Brand, A> IndexedFoldFunc<'a, I, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, A> for Folded<Brand>where
Brand: FoldableWithIndex<I>,
A: 'a,
I: 'a,
§Type Parameters
'a: The lifetime of the values.
I: The index type.
Brand: The brand of the foldable structure.
A: The type of the elements in the structure.
impl<'a, I, Brand, A> IndexedFoldFunc<'a, I, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, A> for Folded<Brand>where
Brand: FoldableWithIndex<I>,
A: 'a,
I: 'a,
§Type Parameters
'a: The lifetime of the values.I: The index type.Brand: The brand of the foldable structure.A: The type of the elements in the structure.
Source§fn apply<R: 'a + Monoid + 'static>(
&self,
f: Box<dyn Fn(I, A) -> R + 'a>,
s: <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>,
) -> R
fn apply<R: 'a + Monoid + 'static>( &self, f: Box<dyn Fn(I, A) -> R + 'a>, s: <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, ) -> R
§Type Signature
forall I Brand A R. (Monoid R, FoldableWithIndex Brand) => (&Folded I Brand A, dyn ((I, A) -> R), Brand A) -> R
§Type Parameters
R: The monoid type.
§Parameters
&self: The folded struct.f: The fold function.s: The structure to fold.
§Returns
The combined monoid value.
§Examples
use fp_library::{
brands::{
VecBrand,
optics::*,
},
types::optics::{
Folded,
IndexedFoldFunc,
},
};
let folded = Folded::<VecBrand>(std::marker::PhantomData);
let result: String =
folded.apply(Box::new(|i: usize, x: i32| format!("[{}]={}", i, x)), vec![10, 20, 30]);
assert_eq!(result, "[0]=10[1]=20[2]=30");Auto Trait Implementations§
impl<Brand> Freeze for Folded<Brand>
impl<Brand> RefUnwindSafe for Folded<Brand>where
Brand: RefUnwindSafe,
impl<Brand> Send for Folded<Brand>where
Brand: Send,
impl<Brand> Sync for Folded<Brand>where
Brand: Sync,
impl<Brand> Unpin for Folded<Brand>where
Brand: Unpin,
impl<Brand> UnsafeUnpin for Folded<Brand>
impl<Brand> UnwindSafe for Folded<Brand>where
Brand: 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more