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

unnecessary transmutes #838

Closed
3 tasks done
Lokathor opened this issue Jul 6, 2019 · 1 comment
Closed
3 tasks done

unnecessary transmutes #838

Lokathor opened this issue Jul 6, 2019 · 1 comment

Comments

@Lokathor
Copy link
Contributor

Lokathor commented Jul 6, 2019

Not sure when this code was written, but by replacing rng.next_u64().to_le() with rng.next_u64().to_le_bytes() we can cut down on some transmutes.

Now, yes, of course to_le_bytes does the transmute internally, but we should avoid unsafe and let the standard library do it as often as possible simply on principle.

That method was stable in 1.32, and the README badge indicates that that's the minimum rust version of rand these days, so it should be an easy change.

Has an old TODO for when the compiler gets to 1.25, which we're at.

@vks
Copy link
Collaborator

vks commented Jul 25, 2019

This was fixed with #840.

@vks vks closed this as completed Jul 25, 2019
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