pub struct TryThunkBrand;Expand description
Brand for TryThunk (Bifunctor).
Trait Implementations§
Source§impl Bifunctor for TryThunkBrand
impl Bifunctor for TryThunkBrand
Source§fn bimap<'a, A: 'a, B: 'a, C: 'a, D: 'a, F, G>(
f: F,
g: G,
p: <Self as Kind_266801a817966495>::Of<'a, A, C>,
) -> <Self as Kind_266801a817966495>::Of<'a, B, D>
fn bimap<'a, A: 'a, B: 'a, C: 'a, D: 'a, F, G>( f: F, g: G, p: <Self as Kind_266801a817966495>::Of<'a, A, C>, ) -> <Self as Kind_266801a817966495>::Of<'a, B, D>
Maps functions over the values in the TryThunk.
This method applies one function to the error value and another to the success value.
§Type Signature
forall self a b c d. Bifunctor self => (a -> b, c -> d, self a c) -> self b d
§Type Parameters
'a: The lifetime of the values.A: The type of the error value.B: The type of the mapped error value.C: The type of the success value.D: The type of the mapped success value.F: The type of the function to apply to the error.G: The type of the function to apply to the success.
§Parameters
f: The function to apply to the error.g: The function to apply to the success.p: TheTryThunkto map over.
§Returns
A new TryThunk containing the mapped values.
§Examples
use fp_library::{brands::*, classes::bifunctor::*, functions::*, types::*};
let x: TryThunk<i32, i32> = TryThunk::pure(5);
assert_eq!(bimap::<TryThunkBrand, _, _, _, _, _, _>(|e| e + 1, |s| s * 2, x).evaluate(), Ok(10));
let y: TryThunk<i32, i32> = TryThunk::err(5);
assert_eq!(bimap::<TryThunkBrand, _, _, _, _, _, _>(|e| e + 1, |s| s * 2, y).evaluate(), Err(6));Source§impl Clone for TryThunkBrand
impl Clone for TryThunkBrand
Source§fn clone(&self) -> TryThunkBrand
fn clone(&self) -> TryThunkBrand
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for TryThunkBrand
impl Debug for TryThunkBrand
Source§impl Default for TryThunkBrand
impl Default for TryThunkBrand
Source§fn default() -> TryThunkBrand
fn default() -> TryThunkBrand
Returns the “default value” for a type. Read more
Source§impl Hash for TryThunkBrand
impl Hash for TryThunkBrand
Source§impl Kind_266801a817966495 for TryThunkBrand
Generated implementation of Kind_266801a817966495 for TryThunkBrand.
impl Kind_266801a817966495 for TryThunkBrand
Generated implementation of Kind_266801a817966495 for TryThunkBrand.
Source§impl Ord for TryThunkBrand
impl Ord for TryThunkBrand
Source§fn cmp(&self, other: &TryThunkBrand) -> Ordering
fn cmp(&self, other: &TryThunkBrand) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for TryThunkBrand
impl PartialEq for TryThunkBrand
Source§impl PartialOrd for TryThunkBrand
impl PartialOrd for TryThunkBrand
impl Copy for TryThunkBrand
impl Eq for TryThunkBrand
impl StructuralPartialEq for TryThunkBrand
Auto Trait Implementations§
impl Freeze for TryThunkBrand
impl RefUnwindSafe for TryThunkBrand
impl Send for TryThunkBrand
impl Sync for TryThunkBrand
impl Unpin for TryThunkBrand
impl UnwindSafe for TryThunkBrand
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