pub fn apply_second<'a, Brand: Kind_cdc7cd43dac7585f, A: 'a, B: 'a, FA, Marker>(
fa: FA,
fb: <FA as ApplySecondDispatch<'a, Brand, A, B, Marker>>::FB,
) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>where
FA: ApplySecondDispatch<'a, Brand, A, B, Marker>,Expand description
Sequences two applicative actions, keeping the result of the second.
Dispatches to either ApplySecond::apply_second or
RefApplySecond::ref_apply_second based on whether the containers
are owned or borrowed.
The Marker type parameter is inferred automatically by the
compiler from the container arguments. Callers write
apply_second::<Brand, _, _>(...) and never need to specify
Marker explicitly.
The dispatch is resolved at compile time with no runtime cost.
§Type Signature
forall Brand A B. ApplySecond Brand => (FA, Brand B) -> Brand B
§Type Parameters
'a: The lifetime of the values.Brand: The brand of the applicative.A: The type of the value(s) inside the first container.B: The type of the value(s) inside the second container.FA: The first container type (owned or borrowed), inferred from the argument.Marker: Dispatch marker type, inferred automatically.
§Parameters
fa: The first container (its values are discarded).fb: The second container (its values are preserved).
§Returns
A container preserving the values from the second input.
§Examples
use fp_library::{
brands::*,
functions::explicit::*,
};
// Owned: dispatches to ApplySecond::apply_second
let y = apply_second::<OptionBrand, _, _, _, _>(Some(5), Some(10));
assert_eq!(y, Some(10));
// By-ref: dispatches to RefApplySecond::ref_apply_second
let a = Some(5);
let b = Some(10);
let y = apply_second::<OptionBrand, _, _, _, _>(&a, &b);
assert_eq!(y, Some(10));