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

macro no-std closure-it

Like kotlin it keyword, translate it to closure

6 releases

0.1.5 Apr 21, 2025
0.1.4 Apr 21, 2025

#515 in Procedural macros

Download history 475/week @ 2025-04-16 34/week @ 2025-04-23

509 downloads per month

MIT license

8KB
129 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