Expand description
§Little-Endian utilities
For cross-platform reproducibility, Little-Endian order (least-significant
part first) has been chosen as the standard for inter-type conversion.
For example, ``next_u64_via_u32] takes
u32values
x, y, then outputs
(y << 32) | x`.
Byte-swapping (like the std to_le
functions) is only needed to convert
to/from byte sequences, and since its purpose is reproducibility,
non-reproducible sources (e.g. OsRng
) need not bother with it.
§Implementing RngCore
Usually an implementation of RngCore
will implement one of the three
methods over its internal source. The following helpers are provided for
the remaining implementations.
fn next_u32
:
self.next_u64() as u32
(self.next_u64() >> 32) as u32
next_u32_via_fill(self)
fn next_u64
:
next_u64_via_u32(self)
next_u64_via_fill(self)
fn fill_bytes
:
fill_bytes_via_next(self, dest)
§Implementing SeedableRng
In many cases, SeedableRng::Seed
must be converted to [u32]
or
[u64]
. The following helpers are provided:
Functions§
- fill_
bytes_ via_ next - Implement
fill_bytes
vianext_u64
andnext_u32
, little-endian order. - next_
u32_ via_ fill - Implement
next_u32
viafill_bytes
, little-endian order. - next_
u64_ via_ fill - Implement
next_u64
viafill_bytes
, little-endian order. - next_
u64_ via_ u32 - Implement
next_u64
vianext_u32
, little-endian order. - read_
u32_ into - Fills
dst: &mut [u32]
fromsrc
- read_
u64_ into - Fills
dst: &mut [u64]
fromsrc