Skip to content
/ lambda Public

Procedural macros for closures with shorthand argument names (like in Swift)

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

kgv/lambda

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lambda

Build Status Build Status License

Procedural macros for closures with shorthand argument names (like in Swift)

Usage

Without arguments (not useful):

let _ = Some("foo").ok_or_else(l!(0));
// expanded:
let _ = Some("foo").ok_or_else(|| 0);

With one explicit argument:

let _ = Some(3).filter(l!($0 % 2 == 0));
// expanded:
let _ = Some(3).filter(|_0| _0 % 2 == 0);

With two explicit arguments:

let _ = [1, 2, 3].iter().fold(0, l!($0 + $1));
// expanded:
let _ = [1, 2, 3].iter().fold(0, |_0, _1| _0 + _1);

With one explicit, one implicit arguments:

let _ = [1, 2, 3].iter().fold(0, l!($1 + 1));
// expanded:
let _ = [1, 2, 3].iter().fold(0, |_, _1| _1 + 1);

etc.

Limitation: the last argument must be explicit.

About

Procedural macros for closures with shorthand argument names (like in Swift)

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages