mirror of https://github.com/smol-rs/fastrand
Merge pull request #33 from aleksanderkrauze/get_seed-feature
Implement `get_seed`
This commit is contained in:
commit
567ee33634
12
src/lib.rs
12
src/lib.rs
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue