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

Enables immutable call chaining on all types.

Example

use chainer::*;

struct HelloWorld;
impl HelloWorld {
    fn print(&self) {
        println!("Hello, world!");
    }
}

fn main() {
    HelloWorld
        .chain(HelloWorld::print)
        .chain(HelloWorld::print)
        .chain(HelloWorld::print);

    // Hello, world!
    // Hello, world!
    // Hello, world!
}

Provided methods

Enables immutable call chaining on all types.

Example
use chainer::*;

struct HelloWorld;
impl HelloWorld {
    fn print(&self) {
        println!("Hello, world!");
    }
}

fn main() {
    HelloWorld
        .chain(HelloWorld::print)
        .chain(HelloWorld::print)
        .chain(HelloWorld::print);

    // Hello, world!
    // Hello, world!
    // Hello, world!
}

Implementors