closure-pass 0.1.0

Proc-macro for specifying kind of passing variables to closures
Documentation
  • Coverage
  • 0%
    0 out of 2 items documented0 out of 1 items with examples
  • Size
  • Source code size: 16.94 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 275.28 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • l4l

closure-pass is a crate for passing arguments to a closure with capture feature of C++ lambdas.

Usage

So far, this crate requires two nightly features: stmt_expr_attributes and proc_macro_hygiene. Usage is pretty straightforward, the following code:

let a = /*..*/;
let b = /*..*/;

#[closure_pass(a, b = b.f()]
move || {
    // ..
}

Will expand to something like:

let a = /*..*/;
let b = /*..*/;

{
    let a = a.clone();
    let b = b.f();
    move || {
        // ..
    }
}