pub fn separate<'a, FA, E: 'a, O: 'a, Marker>(
fa: FA,
) -> (<<FA as InferableBrand_cdc7cd43dac7585f>::Brand as Kind_cdc7cd43dac7585f>::Of<'a, E>, <<FA as InferableBrand_cdc7cd43dac7585f>::Brand as Kind_cdc7cd43dac7585f>::Of<'a, O>)where
FA: InferableBrand_cdc7cd43dac7585f + SeparateDispatch<'a, <FA as InferableBrand_cdc7cd43dac7585f>::Brand, E, O, Marker>,Expand description
Separates a container of Result values into two containers, inferring
the brand from the container type.
The Brand type parameter is inferred from the concrete type of fa
via InferableBrand. Both owned and borrowed containers are supported.
For types with multiple brands, use
explicit::separate with a turbofish.
§Type Signature
forall Brand E O. Compactable Brand => Brand (Result O E) -> (Brand E, Brand O)
§Type Parameters
'a: The lifetime of the values.FA: The container type (owned or borrowed). Brand is inferred from this.E: The error type inside theResultwrappers.O: The success type inside theResultwrappers.Marker: Dispatch marker type, inferred automatically.
§Parameters
fa: The container ofResultvalues (owned or borrowed).
§Returns
A tuple of two containers: Err values and Ok values.
§Examples
use fp_library::functions::*;
let (errs, oks) = separate(vec![Ok(1), Err(2), Ok(3)]);
assert_eq!(oks, vec![1, 3]);
assert_eq!(errs, vec![2]);