func 0.1.0

A crate that helps creating colsures from function pointers
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
use func::func;

fn main() {
    let coeff = 3; // Captured variable
    let add_mul = func! { [coeff] | a, b | {
        let result = (a + b) * coeff;
        println!("Adding {} to {} and multiplying by {} = {}", a, b, coeff, result);
        result
    }};

    assert_eq!(add_mul.call(1, 2), 9);
}