ApplyFirst

Trait ApplyFirst 

Source
pub trait ApplyFirst: Kind1 {
    // Required method
    fn apply_first<'a, A: 'a + Clone, B>(
        fa: Apply1<Self, A>,
    ) -> ArcFn<'a, Apply1<Self, B>, Apply1<Self, A>>
       where Apply1<Self, A>: Clone;
}
Expand description

A typeclass 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. This is useful for executing side effects in sequence while preserving the primary result.

Required Methods§

Source

fn apply_first<'a, A: 'a + Clone, B>( fa: Apply1<Self, A>, ) -> ArcFn<'a, Apply1<Self, B>, Apply1<Self, A>>
where Apply1<Self, A>: Clone,

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

§Type Signature

forall f a b. ApplyFirst f => f a -> f b -> f a

§Parameters
  • fa: The first context containing a value.
  • fb: The second context containing a value (will be discarded).
§Returns

The first context with its value preserved.

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§

Source§

impl ApplyFirst for OptionBrand

Source§

impl ApplyFirst for SoloBrand

Source§

impl ApplyFirst for VecBrand

Source§

impl<E> ApplyFirst for ResultWithErrBrand<E>
where for<'a> E: 'a,

Source§

impl<T> ApplyFirst for ResultWithOkBrand<T>
where for<'a> T: 'a,