How to write a macro which accept a block, but without the outer enclosing brackets

I have tried to use stmt instead, but I got another problem, the semicolon.

macro_rules! test {
    ($($e:stmt);*;) => {$($e)*};
}

fn ok() {
    test! {
        let a = 1;
        let b = 2;
        Vec::<u8>::new();
    }
}

Actually each stmt ignores the semicolon, it is a problem if there is a line that actually return something, and you don't add let _ = in the beginning.

Is there any way to work out this?

macro_rules! test {
    ($($tokens:tt)*) => {$($tokens)*};
}

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.