Implement Rng for Box with alloc feature#227
Conversation
dhardy
left a comment
There was a problem hiding this comment.
I was a bit shocked by the size of this PR, but on closer look I like what you've done!
src/lib.rs
Outdated
|
|
||
| #[cfg(feature="std")] | ||
| #[cfg(all(feature="alloc", not(feature="std")))] | ||
| use alloc::boxed::Box; |
There was a problem hiding this comment.
I'd prefer if you put the use statement above, near #[cfg(feature="std")] use std::rc::Rc;.
src/reseeding.rs
Outdated
|
|
||
| // To test that `fill_bytes` actually did something, check that the | ||
| // average of `v` is not 0. | ||
| let mut sum = 0.0; |
There was a problem hiding this comment.
If you're going to tidy up, might as well just compare the sum here instead of average.
|
Oh, yes, but is the test framework even available? I was wondering about |
|
That was my thought also, but I turns out to work. With everything commented out the PRNG tests run successfully. |
960a4e0 to
a818a01
Compare
a818a01 to
4828506
Compare
|
I have replaced all uses of That took care of just about all errors left. Testing for I did not replace |
|
(I rebased the first 5 commits, I believe a documentation change in chacha made it unmergable. But otherwise didn't touch them) |
|
Nice work! I agree, I don't think it's worth changing the doc-tests. One final thing to do: add those new tests to CI. |
Implement Rng for Box with alloc feature
As discussed in #225 (comment).
I thought to run
cargo test --no-default-features --feature=alloc, but that did not work. Endless compiler warnings.I have included a couple a couple of commits that fix some of the tests that depend on needless memory allocations. Still about 40 compiler errors to go, most of which have to do with
tread_rngnot being available inlib.rs.The test in
lib.rsare where most of the remain problems are, and I didn't feel like fixing them at the moment. Those tests date from 5/6 years ago whenrand.rswas the only file and things were very different. Several are now part of submodules, or could use a close look.So testing on
no_stddoes not work yet, but I hoped to leave that for another PR.