Rust Macro Error: "no rules expected the token `true`"

playground

If a macro get's an expr fragment, it won't evaluate it (even if it is a literal), so $value:expr can never match true. If you want to do value based dispatch, you can't just use macros. You'll need to use traits as well.

like this: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=51d6d30fe845c7be130731b37a9ce840

3 Likes

You are right, thank you very much!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.