Merge pull request #33 from aleksanderkrauze/get_seed-feature

Implement `get_seed`
This commit is contained in:
Taiki Endo 2022-07-24 02:13:39 +09:00 committed by GitHub
commit 567ee33634
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 0 deletions

View File

@ -427,6 +427,12 @@ impl Rng {
self.0.set(seed);
}
/// Gives back **current** seed that is being held by this generator.
#[inline]
pub fn get_seed(&self) -> u64 {
self.0.get()
}
/// Shuffles a slice randomly.
#[inline]
pub fn shuffle<T>(&self, slice: &mut [T]) {
@ -585,6 +591,12 @@ pub fn seed(seed: u64) {
RNG.with(|rng| rng.seed(seed))
}
/// Gives back **current** seed that is being held by the thread-local generator.
#[inline]
pub fn get_seed() -> u64 {
RNG.with(|rng| rng.get_seed())
}
/// Generates a random `bool`.
#[inline]
pub fn bool() -> bool {