Skip to main content

par_compact

Function par_compact 

Source
pub fn par_compact<'a, Brand: ParCompactable, A: 'a + Send>(
    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 in parallel, discarding None values and keeping Some values.

Free function version that dispatches to ParCompactable::par_compact.

§Type Signature

forall Brand A. ParCompactable Brand => Brand (Option A) -> Brand A

§Type Parameters

  • 'a: The lifetime of the elements.
  • Brand: The brand of the compactable structure.
  • A: The type of the elements in the Option.

§Parameters

  • fa: The data structure containing Option values.

§Returns

A new data structure containing only the values from the Some variants.

§Examples

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

let v = vec![Some(1), None, Some(3)];
let result: Vec<i32> = par_compact::<VecBrand, _>(v);
assert_eq!(result, vec![1, 3]);