one obvious kind of trait this would not work for is monoids: e.g. Add Foo<T> + Foo<T> should give you another Foo<T>, not a bare T this delegation pattern bubbles up the result from the inner type without wrapping it
-
Show this thread
-
I really wrote this to get to know the macro system, not because it's a good idea
1 reply 0 retweets 3 likesShow this thread -
stuff like this is why each trait needs it's own derive rules, if it is derivable
1 reply 0 retweets 4 likesShow this thread -
-
-
Replying to @mountain_ghosts
Like r pattern I run into is I'll have some struct A with fields b and c. Except b doesn't impl PartialEq so I can't derive it so I have to write it by hand to match on field c. I just want to go #[derive(PartialEq (c))] and have it work. It's a pattern that's derivable
2 replies 0 retweets 1 like -
Replying to @mgattozzi
ah right yes this macro lets you write delegate_trait!(PartialEq, A => c)
1 reply 0 retweets 1 like -
-
Replying to @mgattozzi
now I need to know how to write it as an attribute rather than a proc-macro
2 replies 0 retweets 1 like -
Replying to @mountain_ghosts @mgattozzi
A few pointers that might be helpful: - https://astexplorer.net/ can be used to explore Rust - the syn + quote + proc-macro2 crates are generally useful (and usually require flags to be turned on to be useful!) - if things end up looking wild, that's okay:https://github.com/yoshuawuyts/context-attribute/blob/master/src/lib.rs#L108-L116 …
1 reply 0 retweets 0 likes
Oh also, proc macro crates need to be marked as such in Cargo.toml, can only export proc macros, and everything has to live in a single file. And re-exporting proc macros from another crate will always look like "re-export foo from bar" even if you use `#[doc(inline)]`.
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.