Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong output in 'Captures and Expansion Redux' chapter #42

Open
padix-key opened this issue Mar 30, 2020 · 1 comment
Open

Wrong output in 'Captures and Expansion Redux' chapter #42

padix-key opened this issue Mar 30, 2020 · 1 comment

Comments

@padix-key
Copy link

The Captures and Expansion Redux chapter states that the following Rust code

macro_rules! capture_expr_then_stringify {
    ($e:expr) => {
        stringify!($e)
    };
}

fn main() {
    println!("{:?}", stringify!(dummy(2 * (1 + (3)))));
    println!("{:?}", capture_expr_then_stringify!(dummy(2 * (1 + (3)))));
}

produces the following output:

"dummy ( 2 * ( 1 + ( 3 ) ) )"
"dummy(2 * (1 + (3)))"

But executing the code on Rust Playground gives me:

"dummy (2 * (1 + (3)))"
"dummy(2 * (1 + (3)))"
@bjorn3
Copy link

bjorn3 commented Mar 30, 2020

Rustc probably changed how it pretty prints since the code was written. Both results are fine, as they parse to the same expression.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants