danielhenrymantilla / macro_rules_attribute-rs

Use declarative macros as proc_macro attributes or derives
https://docs.rs/macro-rules-attribute
Apache License 2.0
102 stars 10 forks source link

Fix readme to reference macro_rules_derive #13

Closed douglas-raillard-arm closed 1 year ago

douglas-raillard-arm commented 1 year ago

README.md currently contains this snippet:

macro_rules! MyFancyDerive { /* … */ }

#[derive(MyFancyDerive!)]
struct Foo { /* … */ }

This will not compile. From my understanding of this code https://github.com/danielhenrymantilla/macro_rules_attribute-rs/blob/f7514b6752066a1fbac272c5a657190965915f7d/src/lib.rs#L224 it should contain this instead:

#[macro_rules_derive(MyFancyDerive!)]
danielhenrymantilla commented 1 year ago

That example was indeed missing an explanation; a fix for that was submitted a few days ago (issue: #11, pr: #12), and it has just been merged:

https://github.com/danielhenrymantilla/macro_rules_attribute-rs/blob/181640ca57c78fa49f1950ccd9222387d1699568/README.md#L15

The idea is that you need to use the #[derive] of this crate rather than the built-in one, precisely to support "banged Derive!s"

douglas-raillard-arm commented 1 year ago

Ah ok makes sense, I did not realize the crate overrides the derive() attribute itself. I did not even know it was possible to do so, Rust is really quite flexible.