You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 by Option::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:
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:
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: