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

UnsafeFromPrimitive ignores default/alternatives #112

Merged
merged 3 commits into from
Mar 25, 2023

Conversation

illicitonion
Copy link
Owner

Previously it would fail to derive, but there are valid use-cases for wanting to perform the unsafe conversion for known "natural" values.

This potentially opens up a bit of confusion around what the behaviours are when these attributes are present but ignored, but these are also documented, and if someone is reaching for this unsafe function rather than using {,Try}FromPrimitive or just an as cast, presumably they're paying attention...

Fixes #32

@illicitonion
Copy link
Owner Author

I'm not sure this is a positive change, but am open to discussion...

Previously it would fail to derive, but there are valid use-cases for
wanting to perform the unsafe conversion for known "natural" values.

This potentially opens up a bit of confusion around what the behaviours
are when these attributes are present but ignored, but these are also
documented, and if someone is reaching for this unsafe function rather
than using `{,Try}FromPrimitive` or just an `as` cast, presumably
they're paying attention...
Copy link
Collaborator

@danielhenrymantilla danielhenrymantilla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that with the added documentation it should be fine, yeah ✅.

  • (Although I almost wish the from_unchecked() function were renamed to transmute_from at that point, just to be extra clear. Not something I am seriously suggesting, just something that we could keep on the back of our mind before a 1.0 release, for instance 🙂)

README.md Show resolved Hide resolved
illicitonion and others added 2 commits March 20, 2023 00:28
Co-authored-by: Daniel Henry-Mantilla <daniel.henry.mantilla@gmail.com>
@illicitonion illicitonion merged commit e02abdc into main Mar 25, 2023
@illicitonion illicitonion deleted the unsafe-ignores-attr branch March 25, 2023 10:35
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

Successfully merging this pull request may close these issues.

Why no alternative and default for UnsafeFromPrimitive ?
2 participants