Expand description
Dispatch for filterable operations:
Filterable and
RefFilterable.
Provides the following dispatch traits and unified free functions:
FilterMapDispatch+explicit::filter_mapFilterDispatch+explicit::filterPartitionDispatch+explicit::partitionPartitionMapDispatch+explicit::partition_map
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§
- Filter
Dispatch - Trait that routes a filter operation to the appropriate type class method.
- Filter
MapDispatch - Trait that routes a filter_map operation to the appropriate type class method.
- Partition
Dispatch - Trait that routes a partition operation to the appropriate type class method.
- Partition
MapDispatch - 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.