[][src]Trait kai::Bind

pub trait Bind: Sized {
    fn bind<F>(self, f: F) -> Self
    where
        F: FnMut(&mut Self)
, { ... } }

Allows the binding and mutation of a value in a single line

This is useful when you want a functional interface wrapping a mutable one, or when you really feel like doing something in one line.

Example

use kai::*;

// Turn this
let mut a = vec![1, 4, 2, 1, 3, 2, 2];
a.sort();
a.dedup();

// Into this
let b = vec![1, 4, 2, 1, 3, 2, 2].bind(|v| v.sort()).bind(Vec::dedup);

assert_eq!(a, b);

Provided methods

fn bind<F>(self, f: F) -> Self where
    F: FnMut(&mut Self), 

Binds the value, mutates it, and returns it

Loading content...

Implementors

impl<T> Bind for T[src]

fn bind<F>(self, f: F) -> Self where
    F: FnMut(&mut Self), 
[src]

Loading content...