#closures #proc-macro #lambda #it #no-alloc

macro no-std closure-it

Like kotlin it keyword, translate it to closure

6 releases

new 0.1.5 Apr 21, 2025
0.1.4 Apr 21, 2025

#843 in Procedural macros

Download history 306/week @ 2025-04-14

318 downloads per month

MIT license

8KB
128 lines

Like kotlin it keyword, translate it to closure

Examples

#[closure_it::closure_it]
fn main() {
    assert_eq!([0i32, 1, 2].map(it+2), [2, 3, 4]);
    assert_eq!([0i32, -1, 2].map(it.abs()), [0, 1, 2]);
    assert_eq!(Some(2).map_or(3, it*2), 4);
}
#[closure_it::closure_it(this)]
fn main() {
    assert_eq!([0i32, 1, 2].map(this+2), [2, 3, 4]);
    assert_eq!([0i32, -1, 2].map(this.abs()), [0, 1, 2]);
    assert_eq!(Some(2).map_or(3, this*2), 4);
}

No runtime deps