Skip to main content

apply_second

Function apply_second 

Source
pub fn apply_second<'a, FA, A: 'a, B: 'a, Marker>(
    fa: FA,
    fb: <FA as ApplySecondDispatch<'a, <FA as InferableBrand_cdc7cd43dac7585f>::Brand, A, B, Marker>>::FB,
) -> <<FA as InferableBrand_cdc7cd43dac7585f>::Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>
Expand description

Sequences two applicative actions, keeping the result of the second, inferring the brand from the container type.

The Brand type parameter is inferred from the concrete type of fa via InferableBrand. Both owned and borrowed containers are supported.

For types with multiple brands, use explicit::apply_second with a turbofish.

§Type Signature

forall Brand A B. ApplySecond Brand => (Brand A, Brand B) -> Brand B

§Type Parameters

  • 'a: The lifetime of the values.
  • FA: The first container type (owned or borrowed). Brand is inferred from this.
  • A: The type of the value(s) inside the first container.
  • B: The type of the value(s) inside the second container.
  • 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::functions::*;

assert_eq!(apply_second(Some(5), Some(10)), Some(10));

let a = Some(5);
let b = Some(10);
assert_eq!(apply_second(&a, &b), Some(10));