Skip to main content

FilterDispatch

Trait FilterDispatch 

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

Trait that routes a filter 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.
  • 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, A>

Perform the dispatched filter operation.

§Type Signature

(self, FA) -> Brand A

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

A new filterable instance containing only the values for which the predicate returned true.

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

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

Implementors§

Source§

impl<'a, 'b, Brand, A, F> FilterDispatch<'a, Brand, A, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Ref> for F
where Brand: RefFilterable, A: 'a + Clone, F: Fn(&A) -> bool + 'a,

Routes Fn(&A) -> bool closures to RefFilterable::ref_filter.

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.
  • F: The closure type.
Source§

impl<'a, Brand, A, F> FilterDispatch<'a, Brand, A, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Val> for F
where Brand: Filterable, A: 'a + Clone, F: Fn(A) -> bool + 'a,

Routes Fn(A) -> bool closures to Filterable::filter.

§Type Parameters
  • 'a: The lifetime of the values.
  • Brand: The brand of the filterable.
  • A: The type of the value(s) inside the filterable.
  • F: The closure type.