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

SOS: macro_rules log not working. need a correct example #116

Open
aqrun opened this issue Oct 11, 2023 · 0 comments
Open

SOS: macro_rules log not working. need a correct example #116

aqrun opened this issue Oct 11, 2023 · 0 comments
Labels
question Further information is requested

Comments

@aqrun
Copy link

aqrun commented Oct 11, 2023

From chapter 4.6 Debugging

in the lib.rs file added:

#[macro_export]
macro_rules! log {
    ( $( &t:tt )* ) => {
        web_sys::console::log_1(&format!( &( &t )* ).into());
    }
}

log!("test data {}", 1);

then run wasm-pack build it prints:

error: no rules expected the token `"test data {}"`
  --> src/lib.rs:16:6
   |
10 | macro_rules! log {
   | ---------------- when calling this macro
...
16 | log!("test data {}", 1);
   |      ^^^^^^^^^^^^^^ no rules expected this token in macro call
   |
   = note: while trying to match sequence start

error: could not compile `wasm-game-of-life` (lib) due to previous error

could anyone give a correct code. thanks!!

@aqrun aqrun added the question Further information is requested label Oct 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant