| Crates.io | bind2 |
| lib.rs | bind2 |
| version | 0.1.0 |
| created_at | 2025-08-13 19:36:05.890979+00 |
| updated_at | 2025-08-13 19:36:05.890979+00 |
| description | Generate some let statements, similar to bind, but very lightweight |
| homepage | |
| repository | https://github.com/A4-Tacks/bind2-rs |
| max_upload_size | |
| id | 1794009 |
| size | 5,801 |
Generate some let statements
Similar to bind, but very lightweight
grammar = *(atom ,) [atom]
atom = [mut] *prefix name *non-comma
prefix = & / * / mut
name = ident / { ident }
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());
};