Skip to main content

SendRefApplyFirst

Trait SendRefApplyFirst 

Source
pub trait SendRefApplyFirst: SendRefLift + Kind_cdc7cd43dac7585f {
    // Provided method
    fn send_ref_apply_first<'a, A: Clone + Send + Sync + 'a, B: Send + Sync + 'a>(
        fa: &<Self as Kind_cdc7cd43dac7585f>::Of<'a, A>,
        fb: &<Self as Kind_cdc7cd43dac7585f>::Of<'a, B>,
    ) -> <Self as Kind_cdc7cd43dac7585f>::Of<'a, A> { ... }
}
Expand description

A type class for combining two thread-safe by-ref contexts, keeping the first value.

Requires A: Clone + Send + Sync because the closure receives &A and must produce an owned A. The default implementation uses SendRefLift::send_ref_lift2.

Provided Methods§

Source

fn send_ref_apply_first<'a, A: Clone + Send + Sync + 'a, B: Send + Sync + 'a>( fa: &<Self as Kind_cdc7cd43dac7585f>::Of<'a, A>, fb: &<Self as Kind_cdc7cd43dac7585f>::Of<'a, B>, ) -> <Self as Kind_cdc7cd43dac7585f>::Of<'a, A>

Combines two contexts, keeping the value from the first.

§Type Signature

forall A B. (&Self A, &Self B) -> Self A

§Type Parameters
  • 'a: The lifetime of the values.
  • A: The type of the value in the first context. Must be Clone + Send + Sync.
  • 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::*,
	classes::*,
	types::*,
};

let x = ArcLazy::new(|| 3);
let y = ArcLazy::new(|| 4);
let result = LazyBrand::<ArcLazyConfig>::send_ref_apply_first(&x, &y);
assert_eq!(*result.evaluate(), 3);

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<Brand: SendRefLift> SendRefApplyFirst for Brand

Blanket implementation of SendRefApplyFirst.

§Type Parameters
  • Brand: The brand type.