rust-random / rand

A Rust library for random number generation.
https://crates.io/crates/rand
Other
1.68k stars 430 forks source link

Added ser/de to `SmallRng`, as it #1360

Closed CGMossa closed 12 months ago

CGMossa commented 12 months ago

I've added Serialize/Deserialize derive to SmallRng. It was one of the non-cryptographic number generators, and it wraps around ser/de-ble types anyways.

Also, I tried running cargo +nightly fmt, and 60 files changed. Is that normal? I'm not gonna push those.

CGMossa commented 12 months ago

Failing test seems unrelated to what I've done here:

error[E0405]: cannot find trait `SimdPartialOrd` in this scope
   --> src/distributions/other.rs:183:21
    |
183 |     Simd<T, LANES>: SimdPartialOrd<Mask = Mask<T, LANES>>,
    |                     ^^^^^^^^^^^^^^
   --> /rustc/0e2dac8375950a12812ec65868e42b43ed214ef9/library/core/src/cmp.rs:1082:1
    |
    = note: similarly named trait `PartialOrd` defined here
    |
help: a trait with a similar name exists
    |
183 |     Simd<T, LANES>: PartialOrd<Mask = Mask<T, LANES>>,
    |                     ~~~~~~~~~~
help: consider importing one of these items
    |
11  + use core::simd::prelude::SimdPartialOrd;
    |
11  + use std::simd::prelude::SimdPartialOrd;
    |
11  + use zerocopy::macro_util::core_reexport::simd::prelude::SimdPartialOrd;
CGMossa commented 12 months ago

Also, this is not getting done due to https://github.com/rust-random/rand/issues/1101

dhardy commented 12 months ago

This won't happen because SmallRng is deliberately not portable.

Use something like Xoshiro.