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

Replace unsafe with to_bits() #63

Merged
merged 2 commits into from
Jan 18, 2022
Merged

Replace unsafe with to_bits() #63

merged 2 commits into from
Jan 18, 2022

Conversation

ilya-bobyr
Copy link
Contributor

While to_bits() is implemented as unsafe { mem::transmute(self) } it seems nicer to rely on the standard library to hide the unsafe implementation. Some people audit the libraries they use and may get nervous when they see unsafe.

@torokati44
Copy link
Contributor

Clippy also warns about this, suggesting a similar fix.

While `to_bits()`[1] is implemented as `unsafe { mem::transmute(self) }`
it seems nicer to rely on the standard library to hide the unsafe
implementation.  Some people audit the libraries they use and may get
nervous when they see `unsafe`.

[1] https://doc.rust-lang.org/std/primitive.f32.html#method.to_bits
@ilya-bobyr ilya-bobyr reopened this Sep 30, 2021
@ilya-bobyr
Copy link
Contributor Author

Rebased against master.

@sebcrozet sebcrozet merged commit ee07aef into brendanzab:master Jan 18, 2022
@sebcrozet
Copy link
Collaborator

LGTM, thanks!

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.

3 participants