closures 0.1.2

Abstraction for seperating code and state in closures
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
extern crate closures;

use closures::RecClosure1;

fn main() {
    let mult5 = RecClosure1::new(5, |this, n| {
        if n > 0 {
            this.state() + this(n-1)
        }
        else {
            0
        }
    });

    println!("{}", mult5(9));

    assert_eq!(mult5(9), 45);
}