Add le module, to be moved to rand_core later#228
Add le module, to be moved to rand_core later#228dhardy wants to merge 2 commits intorust-random:masterfrom
Conversation
Copied from dhardy/master, minus single-read functions, with extra tests
| Why not just depend on the |
pitdicker left a comment
There was a problem hiding this comment.
Nice! You have really paved the road for SeedableRng. Two minor comments.
Yes, I would like to update SeedableRng. It will probably Saturday that I can do it.
src/le.rs Outdated
| @@ -0,0 +1,73 @@ | |||
| // Copyright 2017-2018 The Rust Project Developers. See the COPYRIGHT | |||
| // file at the top-level directory of this distribution and at | |||
| // http://rust-lang.org/COPYRIGHT. | |||
There was a problem hiding this comment.
Shall we try to keep @GabrielMajeri happy 😄? (https vs http)
| //! useful functions available. | ||
| | ||
| // TODO: eventually these should be exported somehow | ||
| #![allow(unused)] |
There was a problem hiding this comment.
I have not tested it, but the functions are public and this should not be necessary?
There was a problem hiding this comment.
The module's not public, at least not yet (plan is to export from rand-core not rand).
| @clarcharr True. The code is copied from But we need only very little from |
|
But yeah, I sympathize with your view. A concern I'd have here is that the code you're copying contains use of |
| We have had the same problem with I don't think the dependency story for @BurntSushi What would you do if |
| @pitdicker If it were me and I wasn't overly concerned about performance, and it was a tiny amount of code, I'd probably just write the safe variants as small helper functions. If it came to It's a tough call either way! |
| @clarcharr @BurntSushi finally someone has brought up the problem of crate trust, though I think we're a long way from solving this yet. But it's true,
|
| @dhardy What do you think about merging this now, but creating an issue that we should keep track of the amount of unsafe code in |
| @pitdicker in my opinion worrying about @BurntSushi any other thoughts? Otherwise I'll merge this (because it's not much code) and we can potentially open a tracker issue to think about dependencies. |
| I don't see worrying about |
| Is there an easy safe alternative? Sure, using I do believe Anyway, I believe code review, clean interfaces and compiler error-checking are the best tools we have to avoid bugs, and (This isn't to say we shouldn't use an external dependency, just that I don't believe avoiding the use of |
| @dhardy I gave you my thoughts. Do what you will with them. :-) Note that using |
| Hmm, I suppose it could be implemented with bit-shifts instead, but that also has opportunities for errors in the implementation, and is probably harder to review for correctness. (In other words, performance isn't the only cost.) So we don't always agree. Perhaps it comes down to worrying more about memory safety or incorrect results; I admit that I often worry more about the latter, especially in something like |
| With the issue linked above about crate trust on internals my first thought was how
So I also think To be honest I feel in this case for the slice copy functions we are making more noise than they deserve. About using unsafe code or bitshifts here I am partial. The bigger questions how we deal with dependencies and |
| @pitdicker I (finally!) finished merging master back into my branch, so hopefully you can copy a lot of what you need for |
| I completely believe that was no easy merge! Let's hope it doesn't take long before everything is merged here. |
| This is merged into master, but the merge is not visible? Or you did a direct commit? |
| I probably rebased and merged without pushing here. |
Copied from dhardy/master, minus single-read functions, with extra tests
@pitdicker do you want to switch the seed types to byte-array and update
SeedableRng? You did the last changes to this on my branch and it's a little more involved than just a type switch. If you prefer I can just copy the relevant code from that branch rather than try to cherry-pick the commits (especially cc6da7a).