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

Fixes console_dbg! and console! expression output. Bold src info. #174

Merged
merged 2 commits into from Nov 28, 2021

Conversation

Madoshakalaka
Copy link
Contributor

@Madoshakalaka Madoshakalaka commented Nov 26, 2021

    let a = 1;
    gloo_console::console_dbg!("123", a, a + 1);
    gloo_console::console_dbg!(String::from("123"));
    gloo_console::console!(b());

    let b: JsString = "123".into();
    gloo_console::console!(b);

    gloo_console::console!({let c: JsString = "cc".into(); c});

image

Comment on lines -12 to -18
// Use of `match` here is intentional because it affects the lifetimes
// of temporaries - https://stackoverflow.com/a/48732525/1063961
match $val {
tmp => {
$crate::log!(::std::format!("[{}:{}] {} =", ::std::file!(), ::std::line!(), ::std::stringify!($val)), &tmp);
tmp
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is no longer necessary, existed for two reasons:

  1. expression called twice
  2. align lifetimes of multiple expressions

1 won't happen anymore because now both macros only run the expression once and bind them to a variable.
2 is not necessary. It's only needed in cases like assert_eq.

@Madoshakalaka
Copy link
Contributor Author

@hamza1311 had an extra comma that failed the tests. If you can approve the CI, it should pass now

@hamza1311 hamza1311 merged commit 91eb9e0 into rustwasm:master Nov 28, 2021
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

Successfully merging this pull request may close these issues.

None yet

2 participants