pub fn compact<'a, Brand: Compactable, A: 'a>(
fa: <Brand as Kind_cdc7cd43dac7585f>::Of<'a, <OptionBrand as Kind_cdc7cd43dac7585f>::Of<'a, A>>,
) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>Expand description
Compacts a data structure of Options, discarding None values and keeping Some values.
Free function version that dispatches to the type class’ associated function.
§Type Signature
forall a f. Compactable f => f (Option a) -> f a
§Type Parameters
Brand: The brand of the compactable structure.A: The type of the elements in theOption.
§Parameters
fa: The data structure containingOptionvalues.
§Returns
A new data structure containing only the values from the Some variants.
§Examples
use fp_library::classes::compactable::compact;
use fp_library::brands::OptionBrand;
let x = Some(Some(5));
let y = compact::<OptionBrand, _>(x);
assert_eq!(y, Some(5));