tlborm icon indicating copy to clipboard operation
tlborm copied to clipboard

Add macro_rules mixed hygiene capture local variables example

Open A4-Tacks opened this issue 1 year ago • 0 comments

fn main() {
    let mut x = 2;
    macro_rules! bind {
        () => { x };
    }
    let x = 2; // shadow
    bind!() += 1;
    assert_eq!(x, 2);
    assert_eq!(bind!(), 3);
}

A4-Tacks avatar Nov 13 '24 05:11 A4-Tacks