Skip to content
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

Provide AsRef<Primitive> implementation #131

Open
FreeMasen opened this issue Sep 6, 2023 · 1 comment
Open

Provide AsRef<Primitive> implementation #131

FreeMasen opened this issue Sep 6, 2023 · 1 comment

Comments

@FreeMasen
Copy link

I am curious if you would be interested in providing a derive implementation to allow AsRef<Primitive>. I have found when attempting to use this crate with some of the standard collections can start to get complicated. It would be nice to have a way to return a &'static Primitive from any given instance of Enum. I threw together a POC of what this might look like here. If you are interested in change I can open this PR against the main branch.

Thanks for this awesome crate!

@illicitonion
Copy link
Owner

Hello! Thanks for the thoughts and POC! I think implementation-wise, that looks pretty reasonable. I'm curious if you have an example or two of where you've needed this in real code - I haven't really hit such a need, and I can kind of imagine the shape of where it may be useful but not quite a full use-case.

Either way, feel free to put together a PR :)

A couple of questions on the code itself:

  1. Should be add an explicit 'static lifetime to the returned refs?
  2. Can you add a section to the root README.md basically duplicating the rustdoc from derive_as_ref_primitive?

Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants