Skip to main content

ref_apply_first

Function ref_apply_first 

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

Combines two contexts, keeping the value from the first.

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

§Type Signature

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

§Type Parameters

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

§Parameters

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

§Returns

A new context containing the value from the first context.

§Examples

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

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