bind2

Crates.iobind2
lib.rsbind2
version0.1.0
created_at2025-08-13 19:36:05.890979+00
updated_at2025-08-13 19:36:05.890979+00
descriptionGenerate some let statements, similar to bind, but very lightweight
homepage
repositoryhttps://github.com/A4-Tacks/bind2-rs
max_upload_size
id1794009
size5,801
A4-Tacks (A4-Tacks)

documentation

README

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());
};
Commit count: 0

cargo fmt