Open spersson opened 6 years ago
This seems a fair enough request. I’d add to it where
clauses, though that’ll require the “only core” invocation to change.
My first attempt at implementing it, however, is failing due to what looks like macro hygiene, and my recollection of the workaround for that seems no longer to work. (It’s been a few years since I’ve written any bleeding-edge macros.)
We could contemplate switching it to a derive attribute, which would save duplication of name and bounds and make it work, but it’s not actually deriving a trait (rather it’s adding methods to the trait object), so something like #[derive(AnyMethods)]
with an optional #[mopa_only_core]
attribute doesn’t feel quite right. I may consult with others to reckon whether it seems reasonable or not.
downcast-rs already supports generic type parameters, so you could use that for inspiration. From my own trials with macros, I'd say this is possible in most cases using declarative macros, but sometimes painful and I could never get good support for lifetimes. Procedural macros are much more capable, yet that requires another crate.
BTW why are there two crates doing exactly the same thing?
mopa predates downcast-rs by almost a year. I have never actually looked into downcast-rs, so I’m not sure what the differences may be.
downcast-rs supports generics but not no_std
and doesn't bother with your __
imports module (presumably because if you assume std
then the names are predictable enough).
error: no rules expected the token
<
Is there any simple work-around?