pub struct ResultBrand;Expand description
Brand for Result.
Trait Implementations§
Source§impl Bifunctor for ResultBrand
impl Bifunctor for ResultBrand
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 result.
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: The result to map over.
§Returns
A new result containing the mapped values.
§Examples
use fp_library::{brands::*, classes::bifunctor::*, functions::*};
let x: Result<i32, i32> = Ok(5);
assert_eq!(bimap::<ResultBrand, _, _, _, _, _, _>(|e| e + 1, |s| s * 2, x), Ok(10));
let y: Result<i32, i32> = Err(5);
assert_eq!(bimap::<ResultBrand, _, _, _, _, _, _>(|e| e + 1, |s| s * 2, y), Err(6));Source§impl Clone for ResultBrand
impl Clone for ResultBrand
Source§fn clone(&self) -> ResultBrand
fn clone(&self) -> ResultBrand
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 ResultBrand
impl Debug for ResultBrand
Source§impl Default for ResultBrand
impl Default for ResultBrand
Source§fn default() -> ResultBrand
fn default() -> ResultBrand
Returns the “default value” for a type. Read more
Source§impl Hash for ResultBrand
impl Hash for ResultBrand
Source§impl Kind_266801a817966495 for ResultBrand
Generated implementation of Kind_266801a817966495 for ResultBrand.
impl Kind_266801a817966495 for ResultBrand
Generated implementation of Kind_266801a817966495 for ResultBrand.
Source§impl Kind_5b1bcedfd80bdc16 for ResultBrand
Generated implementation of Kind_5b1bcedfd80bdc16 for ResultBrand.
impl Kind_5b1bcedfd80bdc16 for ResultBrand
Generated implementation of Kind_5b1bcedfd80bdc16 for ResultBrand.
Source§impl Ord for ResultBrand
impl Ord for ResultBrand
Source§fn cmp(&self, other: &ResultBrand) -> Ordering
fn cmp(&self, other: &ResultBrand) -> 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 ResultBrand
impl PartialEq for ResultBrand
Source§impl PartialOrd for ResultBrand
impl PartialOrd for ResultBrand
impl Copy for ResultBrand
impl Eq for ResultBrand
impl StructuralPartialEq for ResultBrand
Auto Trait Implementations§
impl Freeze for ResultBrand
impl RefUnwindSafe for ResultBrand
impl Send for ResultBrand
impl Sync for ResultBrand
impl Unpin for ResultBrand
impl UnwindSafe for ResultBrand
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