Add documentation for recent functions
CI / cargo fmt (push) Successful in 28s
CI / cargo test (push) Successful in 14m23s
CI / cargo test (GPU) (push) Successful in 13m26s

This commit is contained in:
2026-06-28 15:03:52 -04:00
parent c3224fadd8
commit 3c5563c940
6 changed files with 61 additions and 12 deletions
+22
View File
@@ -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) }
}