Skip to main content

PartitionMapDispatch

Trait PartitionMapDispatch 

Source
pub trait PartitionMapDispatch<'a, Brand: Kind_cdc7cd43dac7585f, A: 'a, E: 'a, O: 'a, FA, Marker> {
    // Required method
    fn dispatch(
        self,
        fa: FA,
    ) -> (<Brand as Kind_cdc7cd43dac7585f>::Of<'a, E>, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, O>);
}
Expand description

Trait that routes a partition_map operation to the appropriate type class method.

The Marker type parameter is an implementation detail resolved by the compiler from the closure’s argument type; callers never specify it directly. The FA type parameter is inferred from the container argument: owned for Val dispatch, borrowed for Ref dispatch.

§Type Parameters

  • 'a: The lifetime of the values.
  • Brand: The brand of the filterable.
  • A: The type of the value(s) inside the filterable.
  • E: The error type produced by the partitioning function.
  • O: The success type produced by the partitioning function.
  • FA: The container type (owned or borrowed), inferred from the argument.
  • Marker: Dispatch marker type, inferred automatically. Either Val or Ref.

Required Methods§

Source

fn dispatch( self, fa: FA, ) -> (<Brand as Kind_cdc7cd43dac7585f>::Of<'a, E>, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, O>)

Perform the dispatched partition_map operation.

§Type Signature

(self, FA) -> (Brand E, Brand O)

§Parameters
  • self: The closure implementing this dispatch.
  • fa: The filterable instance containing the value(s).
§Returns

A tuple of two filterable instances: the first contains the Err values, the second contains the Ok values.

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

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

Implementors§

Source§

impl<'a, 'b, Brand, A, E, O, F> PartitionMapDispatch<'a, Brand, A, E, O, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Ref> for F
where Brand: RefFilterable, A: 'a, E: 'a, O: 'a, F: Fn(&A) -> Result<O, E> + 'a,

Routes Fn(&A) -> Result<O, E> closures to RefFilterable::ref_partition_map.

The container must be passed by reference (&fa).

§Type Parameters
  • 'a: The lifetime of the values.
  • 'b: The borrow lifetime.
  • Brand: The brand of the filterable.
  • A: The type of the value(s) inside the filterable.
  • E: The error type produced by the partitioning function.
  • O: The success type produced by the partitioning function.
  • F: The closure type.
Source§

impl<'a, Brand, A, E, O, F> PartitionMapDispatch<'a, Brand, A, E, O, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Val> for F
where Brand: Filterable, A: 'a, E: 'a, O: 'a, F: Fn(A) -> Result<O, E> + 'a,

Routes Fn(A) -> Result<O, E> closures to Filterable::partition_map.

§Type Parameters
  • 'a: The lifetime of the values.
  • Brand: The brand of the filterable.
  • A: The type of the value(s) inside the filterable.
  • E: The error type produced by the partitioning function.
  • O: The success type produced by the partitioning function.
  • F: The closure type.