Skip to content

Commit 567ee33

Browse files
authored
Merge pull request #33 from aleksanderkrauze/get_seed-feature
Implement `get_seed`
2 parents 5f8bdb6 + 005abc5 commit 567ee33

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/lib.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,12 @@ impl Rng {
427427
self.0.set(seed);
428428
}
429429

430+
/// Gives back **current** seed that is being held by this generator.
431+
#[inline]
432+
pub fn get_seed(&self) -> u64 {
433+
self.0.get()
434+
}
435+
430436
/// Shuffles a slice randomly.
431437
#[inline]
432438
pub fn shuffle<T>(&self, slice: &mut [T]) {
@@ -585,6 +591,12 @@ pub fn seed(seed: u64) {
585591
RNG.with(|rng| rng.seed(seed))
586592
}
587593

594+
/// Gives back **current** seed that is being held by the thread-local generator.
595+
#[inline]
596+
pub fn get_seed() -> u64 {
597+
RNG.with(|rng| rng.get_seed())
598+
}
599+
588600
/// Generates a random `bool`.
589601
#[inline]
590602
pub fn bool() -> bool {

0 commit comments

Comments
 (0)