pub trait ApplyFirst: Lift {
// Provided method
fn apply_first<'a, A: 'a + Clone, B: 'a + Clone>(
fa: <Self as Kind_cdc7cd43dac7585f>::Of<'a, A>,
fb: <Self as Kind_cdc7cd43dac7585f>::Of<'a, B>,
) -> <Self as Kind_cdc7cd43dac7585f>::Of<'a, A> { ... }
}Expand description
A type class for types that support combining two contexts, keeping the first value.
ApplyFirst provides the ability to sequence two computations but discard
the result of the second computation, keeping only the result of the first.
Provided Methods§
Sourcefn apply_first<'a, A: 'a + Clone, B: 'a + Clone>(
fa: <Self as Kind_cdc7cd43dac7585f>::Of<'a, A>,
fb: <Self as Kind_cdc7cd43dac7585f>::Of<'a, B>,
) -> <Self as Kind_cdc7cd43dac7585f>::Of<'a, A>
fn apply_first<'a, A: 'a + Clone, B: 'a + Clone>( fa: <Self as Kind_cdc7cd43dac7585f>::Of<'a, A>, fb: <Self as Kind_cdc7cd43dac7585f>::Of<'a, B>, ) -> <Self as Kind_cdc7cd43dac7585f>::Of<'a, A>
Combines two contexts, keeping the value from the first context.
This function sequences two computations and discards the result of the second computation, keeping only the result of the first.
§Type Signature
forall A B. (Self A, Self B) -> Self A
§Type Parameters
'a: The lifetime of the values.A: The type of the value in the first context.B: The type of the value in the second context.
§Parameters
fa: The first context.fb: The second context.
§Returns
The first context.
§Examples
use fp_library::{brands::*, functions::*};
let x = Some(5);
let y = Some(10);
let z = apply_first::<OptionBrand, _, _>(x, y);
assert_eq!(z, Some(5));Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementors§
impl ApplyFirst for CatListBrand
impl ApplyFirst for IdentityBrand
impl ApplyFirst for OptionBrand
impl ApplyFirst for ThunkBrand
impl ApplyFirst for Tuple1Brand
impl ApplyFirst for VecBrand
impl<A: 'static> ApplyFirst for TryThunkWithOkBrand<A>
§Type Parameters
A: The success type.
impl<DoneType: Clone + 'static> ApplyFirst for StepWithDoneBrand<DoneType>
§Type Parameters
DoneType: The done type.
impl<E: 'static> ApplyFirst for TryThunkWithErrBrand<E>
§Type Parameters
E: The error type.
impl<E: Clone + 'static> ApplyFirst for ResultWithErrBrand<E>
§Type Parameters
E: The error type.
impl<First: Clone + Semigroup + 'static> ApplyFirst for PairWithFirstBrand<First>
§Type Parameters
First: The type of the first value in the pair.
impl<First: Clone + Semigroup + 'static> ApplyFirst for Tuple2WithFirstBrand<First>
§Type Parameters
First: The type of the first value in the tuple.
impl<LoopType: Clone + 'static> ApplyFirst for StepWithLoopBrand<LoopType>
§Type Parameters
LoopType: The loop type.
impl<Second: Clone + Semigroup + 'static> ApplyFirst for PairWithSecondBrand<Second>
§Type Parameters
Second: The type of the second value in the pair.
impl<Second: Clone + Semigroup + 'static> ApplyFirst for Tuple2WithSecondBrand<Second>
§Type Parameters
Second: The type of the second value in the tuple.
impl<T: Clone + 'static> ApplyFirst for ResultWithOkBrand<T>
§Type Parameters
T: The success type.