Trait Bind

Source
pub trait Bind<A, B>: Lift<A, B> {
    // Required method
    fn bind<F>(self, f: F) -> <Self as Lift<A, B>>::Target1
       where F: Fn(A) -> <Self as Lift<A, B>>::Target1;
}
Expand description

Bind lets you chain computations together.

It takes a function Fn(A) -> M<B> and applies it to the A inside M<A>. You can think of this as a callback function for when the value of A is ready to be processed, returning the next computation in the sequence.

Required Methods§

Source

fn bind<F>(self, f: F) -> <Self as Lift<A, B>>::Target1
where F: Fn(A) -> <Self as Lift<A, B>>::Target1,

Use the value inside an M<A>: Bind to create an M<B>.

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.

Implementations on Foreign Types§

Source§

impl<A, B> Bind<A, B> for Option<A>

Source§

fn bind<F>(self, f: F) -> <Self as Lift<A, B>>::Target1
where F: Fn(A) -> <Self as Lift<A, B>>::Target1,

Source§

impl<A, B> Bind<A, B> for BinaryHeap<A>
where A: Ord, B: Ord,

Source§

fn bind<F>(self, f: F) -> <Self as Lift<A, B>>::Target1
where F: Fn(A) -> <Self as Lift<A, B>>::Target1,

Source§

impl<A, B> Bind<A, B> for BTreeSet<A>
where A: Ord, B: Ord,

Source§

fn bind<F>(self, f: F) -> <Self as Lift<A, B>>::Target1
where F: Fn(A) -> <Self as Lift<A, B>>::Target1,

Source§

impl<A, B> Bind<A, B> for LinkedList<A>

Source§

fn bind<F>(self, f: F) -> <Self as Lift<A, B>>::Target1
where F: Fn(A) -> <Self as Lift<A, B>>::Target1,

Source§

impl<A, B> Bind<A, B> for VecDeque<A>

Source§

fn bind<F>(self, f: F) -> <Self as Lift<A, B>>::Target1
where F: Fn(A) -> <Self as Lift<A, B>>::Target1,

Source§

impl<A, B> Bind<A, B> for Vec<A>

Source§

fn bind<F>(self, f: F) -> <Self as Lift<A, B>>::Target1
where F: Fn(A) -> <Self as Lift<A, B>>::Target1,

Source§

impl<A, B, C, D> Bind<(A, B), (C, D)> for BTreeMap<A, B>
where A: Ord, B: Ord, C: Ord, D: Ord,

Source§

fn bind<F>(self, f: F) -> <Self as Lift<(A, B), (C, D)>>::Target1
where F: Fn((A, B)) -> <Self as Lift<(A, B), (C, D)>>::Target1,

Source§

impl<A, B, C, D, S> Bind<(A, B), (C, D)> for HashMap<A, B, S>
where A: Hash + Eq, B: Hash + Eq, C: Hash + Eq, D: Hash + Eq, S: BuildHasher + Default,

Source§

fn bind<F>(self, f: F) -> <Self as Lift<(A, B), (C, D)>>::Target1
where F: Fn((A, B)) -> <Self as Lift<(A, B), (C, D)>>::Target1,

Source§

impl<A, B, E> Bind<A, B> for Result<A, E>

Source§

fn bind<F>(self, f: F) -> <Self as Lift<A, B>>::Target1
where F: Fn(A) -> <Self as Lift<A, B>>::Target1,

Source§

impl<A, B, S> Bind<A, B> for HashSet<A, S>
where A: Hash + Eq, B: Hash + Eq, S: BuildHasher + Default,

Source§

fn bind<F>(self, f: F) -> <Self as Lift<A, B>>::Target1
where F: Fn(A) -> <Self as Lift<A, B>>::Target1,

Implementors§