separate

Function separate 

Source
pub fn separate<'a, Brand: Compactable, O: 'a, E: 'a>(
    fa: <Brand as Kind_cdc7cd43dac7585f>::Of<'a, Result<O, E>>,
) -> Pair<<Brand as Kind_cdc7cd43dac7585f>::Of<'a, O>, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, E>>
Expand description

Separates a data structure of Results into two data structures: one containing the Ok values and one containing the Err values.

Free function version that dispatches to the type class’ associated function.

§Type Signature

forall o e f. Compactable f => f (Result o e) -> (f o, f e)

§Type Parameters

  • Brand: The brand of the compactable structure.
  • O: The type of the success values.
  • E: The type of the error values.

§Parameters

  • fa: The data structure containing Result values.

§Returns

A pair of data structures: the first containing the Ok values, and the second containing the Err values.

§Examples

use fp_library::{brands::*, functions::*, types::*};

let x: Option<Result<i32, &str>> = Some(Ok(5));
let Pair(oks, errs) = separate::<OptionBrand, _, _>(x);
assert_eq!(oks, Some(5));
assert_eq!(errs, None);