ApplyFirst

Trait ApplyFirst 

Source
pub trait ApplyFirst: Lift {
    // Provided method
    fn apply_first<'a, A: 'a + Clone, B: 'a + Clone>(
        fa: Apply1L1T<'a, Self, A>,
        fb: Apply1L1T<'a, Self, B>,
    ) -> Apply1L1T<'a, Self, 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§

Source

fn apply_first<'a, A: 'a + Clone, B: 'a + Clone>( fa: Apply1L1T<'a, Self, A>, fb: Apply1L1T<'a, Self, B>, ) -> Apply1L1T<'a, Self, A>

Combines two contexts, keeping the value from the first context.

§Type Signature

forall a b. ApplyFirst f => (f a, f b) -> f a

§Parameters
  • fa: The first context.
  • fb: The second context.
§Returns

The first context.

§Examples
use fp_library::classes::apply_first::ApplyFirst;
use fp_library::brands::OptionBrand;

let x = Some(5);
let y = Some(10);
let z = OptionBrand::apply_first(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§