Skip to main content

ref_apply_second

Function ref_apply_second 

Source
pub fn ref_apply_second<'a, Brand: RefApplySecond, A: 'a, B: Clone + 'a>(
    fa: &<Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>,
    fb: &<Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>,
) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>
Expand description

Combines two contexts, keeping the value from the second.

Free function version that dispatches to the type class’ associated function.

§Type Signature

forall Brand A B. RefApplySecond Brand => (&Brand A, &Brand B) -> Brand B

§Type Parameters

  • 'a: The lifetime of the values.
  • Brand: The brand of the context.
  • A: The type of the value in the first context.
  • B: The type of the value in the second context. Must be Clone.

§Parameters

  • fa: The first context.
  • fb: The second context.

§Returns

A new context containing the value from the second context.

§Examples

use fp_library::{
	brands::*,
	functions::{
		explicit::apply_second,
		*,
	},
	types::*,
};

let x = RcLazy::pure(3);
let y = RcLazy::pure(4);
let result = apply_second::<LazyBrand<RcLazyConfig>, _, _, _, _>(&x, &y);
assert_eq!(*result.evaluate(), 4);