pub fn separate<'a, Brand: Compactable, E: 'a, O: 'a>(
fa: <Brand as Kind_cdc7cd43dac7585f>::Of<'a, Result<O, E>>,
) -> (<Brand as Kind_cdc7cd43dac7585f>::Of<'a, E>, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, O>)Expand description
Separates a data structure of Results into two data structures: one containing the Err values and one containing the Ok values.
Free function version that dispatches to the type class’ associated function.
§Type Signature
forall Brand E O. Compactable Brand => Brand (Result O E) -> (Brand E, Brand O)
§Type Parameters
'a: The lifetime of the elements.Brand: The brand of the compactable structure.E: The type of the error values.O: The type of the success values.
§Parameters
fa: The data structure containingResultvalues.
§Returns
A pair of data structures: the first containing the Err values, and the second containing the Ok values.
§Examples
use fp_library::{brands::*, functions::*};
let x: Option<Result<i32, &str>> = Some(Ok(5));
let (errs, oks) = separate::<OptionBrand, _, _>(x);
assert_eq!(oks, Some(5));
assert_eq!(errs, None);