pub trait CallChainMut {
    fn chain_mut<R, F: FnOnce(&mut Self) -> R>(&mut self, f: F) -> &mut Self { ... }
}
Expand description

Enables mutable call chaining on all types.

Example

use chainer::*;

struct Counter { value: i32 }
impl Counter {
    fn increment(&mut self) {
        self.value += 1;
        println!("{}", self.value);
    }
}

fn main() {
    Counter { value: 0 }
        .chain_mut(Counter::increment)
        .chain_mut(Counter::increment)
        .chain_mut(Counter::increment);

    // 1
    // 2
    // 3
}

Provided methods

Enables mutable call chaining on all types.

Example
use chainer::*;

struct Counter { value: i32 }
impl Counter {
    fn increment(&mut self) {
        self.value += 1;
        println!("{}", self.value);
    }
}

fn main() {
    Counter { value: 0 }
        .chain_mut(Counter::increment)
        .chain_mut(Counter::increment)
        .chain_mut(Counter::increment);

    // 1
    // 2
    // 3
}

Implementors