Transparent closures with Func!
Hey everyone, I just released my very first crate: func. What it does is allow you to create closures where the captured data and the function body is stored separately. This enables you to see the captured types and values and even implement traits for them based on their types. Here's an example for how to create one:
let coeff = 3;
let add_mul = func! { [coeff] | a, b | {
println!("Adding {} to {} and multiplying by {}", a, b, coeff);
(a + b) * coeff
}};
assert_eq!(add_mul.call(1, 2), 9);
Check out more examples on when and what way it improves closures and try it out: https://crates.io/crates/func
P.S.: I couldn't believe that the func crate name was available