pub struct Forget<'a, PointerBrand, R, A, B>(pub <FnBrand<PointerBrand> as Kind_266801a817966495>::Of<'a, A, R>, _)
where
PointerBrand: UnsizedCoercible,
R: 'a,
A: 'a;Expand description
The Forget profunctor.
Forget<P, R, A, B> is a profunctor that ignores its second type argument B
and instead stores a function from A to R.
§Type Parameters
'a: The lifetime of the values.PointerBrand: The pointer brand.R: The return type of the function.A: The input type of the function.B: The ignored type.
Tuple Fields§
§0: <FnBrand<PointerBrand> as Kind_266801a817966495>::Of<'a, A, R>Implementations§
Source§impl<'a, PointerBrand, R, A, B> Forget<'a, PointerBrand, R, A, B>where
PointerBrand: UnsizedCoercible,
R: 'a,
A: 'a,
§Type Parameters
'a: The lifetime of the values.
PointerBrand: The pointer brand.
R: The return type of the function.
A: The input type of the function.
B: The ignored type.
impl<'a, PointerBrand, R, A, B> Forget<'a, PointerBrand, R, A, B>where
PointerBrand: UnsizedCoercible,
R: 'a,
A: 'a,
§Type Parameters
'a: The lifetime of the values.PointerBrand: The pointer brand.R: The return type of the function.A: The input type of the function.B: The ignored type.
Sourcepub fn new(f: impl Fn(A) -> R + 'a) -> Self
pub fn new(f: impl Fn(A) -> R + 'a) -> Self
Creates a new Forget instance.
§Type Signature
forall PointerBrand R A B. UnsizedCoercible PointerBrand => (A -> R) -> Forget PointerBrand R A B
§Parameters
f: The function to wrap.
§Returns
A new instance of the type.
§Examples
use fp_library::{
brands::RcBrand,
types::optics::Forget,
};
let forget = Forget::<RcBrand, i32, String, i32>::new(|s: String| s.len() as i32);
// Access via the underlying function wrapper, which implements Deref
assert_eq!((forget.0)("hello".to_string()), 5);Sourcepub fn run(&self, a: A) -> R
pub fn run(&self, a: A) -> R
Runs the Forget profunctor on an input.
§Type Signature
forall PointerBrand R A B. UnsizedCoercible PointerBrand => (&Forget PointerBrand R A B, A) -> R
§Parameters
&self: The forget instance.a: The input value.
§Returns
The result of applying the underlying function to the input.
§Examples
use fp_library::{
brands::RcBrand,
types::optics::Forget,
};
let forget = Forget::<RcBrand, i32, String, i32>::new(|s: String| s.len() as i32);
assert_eq!(forget.run("hello".to_string()), 5);Trait Implementations§
Source§impl<'a, PointerBrand, R, A, B> Clone for Forget<'a, PointerBrand, R, A, B>where
PointerBrand: UnsizedCoercible,
R: 'a,
A: 'a,
§Type Parameters
'a: The lifetime of the values.
PointerBrand: The pointer brand.
R: The return type of the function.
A: The input type of the function.
B: The ignored type.
impl<'a, PointerBrand, R, A, B> Clone for Forget<'a, PointerBrand, R, A, B>where
PointerBrand: UnsizedCoercible,
R: 'a,
A: 'a,
§Type Parameters
'a: The lifetime of the values.PointerBrand: The pointer brand.R: The return type of the function.A: The input type of the function.B: The ignored type.
Source§fn clone(&self) -> Self
fn clone(&self) -> Self
§Type Signature
forall PointerBrand R A B. UnsizedCoercible PointerBrand => &Forget PointerBrand R A B -> Forget PointerBrand R A B
§Returns
A new Forget instance that is a copy of the original.
§Examples
use fp_library::{
brands::RcBrand,
types::optics::Forget,
};
let forget = Forget::<RcBrand, i32, String, i32>::new(|s: String| s.len() as i32);
let cloned = forget.clone();
assert_eq!(cloned.run("hello".to_string()), 5);1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl<'a, PointerBrand, R, A, B> Freeze for Forget<'a, PointerBrand, R, A, B>
impl<'a, PointerBrand, R, A, B> RefUnwindSafe for Forget<'a, PointerBrand, R, A, B>where
<PointerBrand as RefCountedPointer>::CloneableOf<'a, dyn Fn(A) -> R + 'a>: RefUnwindSafe,
B: RefUnwindSafe,
impl<'a, PointerBrand, R, A, B> Send for Forget<'a, PointerBrand, R, A, B>
impl<'a, PointerBrand, R, A, B> Sync for Forget<'a, PointerBrand, R, A, B>
impl<'a, PointerBrand, R, A, B> Unpin for Forget<'a, PointerBrand, R, A, B>
impl<'a, PointerBrand, R, A, B> UnsafeUnpin for Forget<'a, PointerBrand, R, A, B>
impl<'a, PointerBrand, R, A, B> UnwindSafe for Forget<'a, PointerBrand, R, A, B>where
<PointerBrand as RefCountedPointer>::CloneableOf<'a, dyn Fn(A) -> R + 'a>: UnwindSafe,
B: 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