Expand description
Generate some let statements
Similar to bind, but very lightweight
§Grammar
grammar = *(atom ,
) [atom]
atom = [mut
] *prefix name *non-comma
prefix = &
/ *
/ mut
name = ident / {
ident }
§Examples
use bind2::bind;
let (x, y, mut z, m, n) = (1, 2, 3, 4, 5);
bind!(x, &y, &mut z, m.to_owned(), mut &n);
Expand to:
let (x, y, mut z, m, n) = (1, 2, 3, 4, 5);
let x = x;
let y = &y;
let z = &mut z;
let m = m.to_owned();
let mut n = &n;
let x = "foo".to_owned();
let mut y = Some(8);
let f = || {
bind2::bind!(mut x, mut y, y.take().unwrap());
x.push_str(&y.to_string());
};
Macros§
- bind
- Generate some let statements