pub fn unless<'a, Brand: Applicative>(
condition: bool,
action: <Brand as Kind_cdc7cd43dac7585f>::Of<'a, ()>,
) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, ()>Expand description
Performs an applicative action unless a condition is true.
Returns the given action if condition is false, otherwise returns pure(()).
§Type Signature
forall Brand. Applicative Brand => (bool, Brand ()) -> Brand ()
§Type Parameters
'a: The lifetime of the computation.Brand: The brand of the applicative.
§Parameters
condition: The condition to check.action: The action to perform if the condition is false.
§Returns
The action if the condition is false, otherwise pure(()).
§Examples
use fp_library::{
brands::*,
functions::*,
};
assert_eq!(unless::<OptionBrand>(false, Some(())), Some(()));
assert_eq!(unless::<OptionBrand>(true, Some(())), Some(()));
assert_eq!(unless::<VecBrand>(false, vec![(), ()]), vec![(), ()]);
assert_eq!(unless::<VecBrand>(true, vec![(), ()]), vec![()]);