Add documentation for recent functions
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
use rand::SeedableRng;
|
||||
use rand_xoshiro::Xoshiro256StarStar;
|
||||
|
||||
/// Convert an RNG state buffer to an instance of [`Xoshiro256StarStar`].
|
||||
///
|
||||
/// While [`SeedableRng::from_seed`] is an infallible function,
|
||||
/// it relies on some methods that can't be compiled by the SPIR-V
|
||||
/// backend (specifically, formatting functions in the core crate).
|
||||
///
|
||||
/// In practice, the xoshiro RNG state is entirely defined by its seed,
|
||||
/// so this function does the work of [`SeedableRng::from_seed`] by
|
||||
/// transmuting the seed value to an RNG instance.
|
||||
///
|
||||
/// This function assumes a properly-initialized state array;
|
||||
/// output may silently degenerate if the initial state is all zeros,
|
||||
/// so this module is private to the crate.
|
||||
pub(crate) fn xoshiro_from_state(
|
||||
_rng_state: <Xoshiro256StarStar as SeedableRng>::Seed,
|
||||
) -> Xoshiro256StarStar {
|
||||
let rng_state_actual = [1u64, 2u64, 3u64, 4u64];
|
||||
unsafe { core::mem::transmute(rng_state_actual) }
|
||||
}
|
||||
Reference in New Issue
Block a user