Skip to main content

Module ref_alt

Module ref_alt 

Source
Expand description

Choosing between values in a context by reference, associatively.

RefAlt is to type constructors with by-reference access as Alt is to type constructors with by-value access. Both containers are borrowed, and A: Clone is required so elements can be cloned out of the references when constructing the result.

§Examples

use fp_library::{
	brands::*,
	classes::*,
	functions::explicit::*,
};

let x: Option<i32> = None;
let y = Some(5);
let z = alt::<OptionBrand, _, _, _>(&x, &y);
assert_eq!(z, Some(5));

Traits§

RefAlt
A type class for associative choice on type constructors, operating by reference.

Functions§

ref_alt
Chooses between two values in a context, operating by reference.