Skip to main content

AltDispatch

Trait AltDispatch 

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

Trait that routes an alt operation to the appropriate type class method.

The Marker type parameter is an implementation detail resolved by the compiler from the container type; callers never specify it directly. Owned containers resolve to Val, borrowed containers resolve to Ref.

§Type Parameters

  • 'a: The lifetime of the values.
  • Brand: The brand of the functor.
  • A: The type of the value(s) inside the functor.
  • Marker: Dispatch marker type, inferred automatically. Either Val or Ref.

Required Methods§

Source

fn dispatch(self, other: Self) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>

Perform the dispatched alt operation.

§Type Signature

(self, Self) -> Brand A

§Parameters
  • self: The container implementing this dispatch.
  • other: The other container to combine with.
§Returns

A new container from the combination of both inputs.

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

let result = alt::<OptionBrand, _, _, _>(None, Some(5));
assert_eq!(result, Some(5));

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<'a, Brand, A> AltDispatch<'a, Brand, A, Ref> for &<Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>
where Brand: RefAlt, A: 'a + Clone,

Routes borrowed containers to RefAlt::ref_alt.

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

impl<'a, Brand, A> AltDispatch<'a, Brand, A, Val> for <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>
where Brand: Alt, A: 'a + Clone,

Routes owned containers to Alt::alt.

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