-
-
Notifications
You must be signed in to change notification settings - Fork 1
Replace block module with helper functions
#24
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
base: master
Are you sure you want to change the base?
Conversation
|
What does this look like at the use site? You could update |
|
Motivation regarding
Not a change.
I explained why I didn't want to do this in rust-random/rand#1667. |
See the new doc examples. I wanted to update the implementation crates after I got a confirmation that you approve the new approach.
True. I will edit the OP.
The problem is that the |
|
All potential panics in
|
|
I improved codegen for |
I really do not want to introduce two separate utility modules. I returned the
I did use them in the examples. I plan to update |
Better to punt the issue to a new PR than to worry overly about it here. More important that this PR is easy to review.
Yes, but examples don't always match up with real usage, so I strongly prefer seeing a new API in a real use-case than just in an example. Doc examples are also harder to review (no highlighting without building docs). |
Co-authored-by: Diggory Hardy <git@dhardy.name>
|
The approach looks broadly okay, not losing much from our previous code. But I cannot approve it without running benchmarks on actual block RNGs, so it does need some downstream implementation before this PR can be approved. |
|
I migrated the rngs repository to this PR, see: rust-random/rngs#78 The only encountered problem is with implementation of Migration of |
|
Another potential issue is |
|
Considering that reseeding should be done using relatively large thresholds, buffer re-initialization is an extremely cheap operation (in practice the additional writes are unlikely to even leave the CPU cache before getting overwritten by a newly generated block), so I don't think it's a deal breaker. |
|
The point was more to avoid needing to test whether to reseed frequently. It may not be necessary still (testing required), but direct access to a block generator would allow a cleaner design of |
This change allows to remove the
serdefeature and reduce total amount of code in the crate. Additionally, the helper block functions now store the cursor position in the first buffer value, which allows us to remove the separateindexfield.The new examples demonstrate implementation of the traits for the most common RNG classes.
TODO: