Skip to main content

Module filterable

Module filterable 

Source
Expand description

Dispatch for filterable operations: Filterable and RefFilterable.

Provides the following dispatch traits and unified free functions:

Each routes to the appropriate trait method based on the closure’s argument type.

§Examples

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

// filter_map: Owned
let y =
	filter_map::<OptionBrand, _, _, _, _>(|x: i32| if x > 3 { Some(x) } else { None }, Some(5));
assert_eq!(y, Some(5));

// filter: Owned
let y = filter::<OptionBrand, _, _, _>(|x: i32| x > 3, Some(5));
assert_eq!(y, Some(5));

// partition: Owned
let (no, yes) = partition::<OptionBrand, _, _, _>(|x: i32| x > 3, Some(5));
assert_eq!(yes, Some(5));
assert_eq!(no, None);

// partition_map: Owned
let (errs, oks) =
	partition_map::<OptionBrand, _, _, _, _, _>(|x: i32| Ok::<i32, i32>(x * 2), Some(5));
assert_eq!(errs, None);
assert_eq!(oks, Some(10));

Modules§

explicit
Explicit dispatch functions requiring a Brand turbofish.

Traits§

FilterDispatch
Trait that routes a filter operation to the appropriate type class method.
FilterMapDispatch
Trait that routes a filter_map operation to the appropriate type class method.
PartitionDispatch
Trait that routes a partition operation to the appropriate type class method.
PartitionMapDispatch
Trait that routes a partition_map operation to the appropriate type class method.

Functions§

filter
Filters the values in a filterable context using a predicate, inferring the brand from the container type.
filter_map
Filters and maps the values in a filterable context, inferring the brand from the container type.
partition
Partitions the values in a filterable context using a predicate, inferring the brand from the container type.
partition_map
Partitions the values using a function returning Result, inferring the brand from the container type.