1个不稳定版本
| 0.1.0 | 2020年5月3日 |
|---|
#10 in #specifying
7KB
78 代码行
closure-pass 是一个用于通过C++ lambdas的捕获特性传递参数到闭包的crate。
用法
到目前为止,这个crate需要两个nightly功能: stmt_expr_attributes 和 proc_macro_hygiene。用法很简单,以下代码
let a = /*..*/;
let b = /*..*/;
#[closure_pass(a, b = b.f()]
move || {
// ..
}
将展开成类似
let a = /*..*/;
let b = /*..*/;
{
let a = a.clone();
let b = b.f();
move || {
// ..
}
}
依赖
~1.5MB
~34K SLoC