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
Add referencing derive for enums #174
Labels
Comments
Ah, since this macro will create a wholly new type, it'd be nice to have a way to specify derives to be placed on it, too. |
On one hand this seems like quite a niche derive, on the other if you have a big enough enum it's really annoying to have to do this by hand. So I think I could see this fit well in the set of static method derives of this crate. Naming wise a few options I can think of:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I want to do this in a PR if someone else can figure out the naming.
Feature
A derive macro that emits a duplicate of the input enum type, but with members now held by reference, and a method for producing an instance of that enum from a reference to the input enum.
Like the
&Option<T> -> Option<&T>
provided byOption::as_ref
, but on any enum.(Also, I'd like a mutable referencing variant of this, like
Option::as_mut
.)Since
AsRef
is already a trait derived by a macro in this crate, we need a different name for this macro.We also need a way to name the new generated type, and to decide whether to try and special case this for generic enums so they don't get an extra type unnecessarily.
(I'm leaning toward not doing such a special case, but it's worth thinking about.)
The text was updated successfully, but these errors were encountered: