rand::reseeding::Reseeder - Rust
Description: API documentation for the Rust `Reseeder` trait in crate `rand`.
Keywords: rust, rustlang, rust-lang, Reseeder

# Trait rand::reseeding::Reseeder [−] [src]

    pub trait Reseeder<R> {
        fn reseed(&mut self, rng: &mut R);
    }

Something that can be used to reseed an RNG via `ReseedingRng`.

# Example

    use rand::{Rng, SeedableRng, StdRng};
    use rand::reseeding::{Reseeder, ReseedingRng};

    struct TickTockReseeder { tick: bool }
    impl Reseeder<StdRng> for TickTockReseeder {
        fn reseed(&mut self, rng: &mut StdRng) {
            let val = if self.tick {0} else {1};
            rng.reseed(&[val]);
            self.tick = !self.tick;
        }
    }
    fn main() {
        let rsdr = TickTockReseeder { tick: true };

        let inner = StdRng::new().unwrap();
        let mut rng = ReseedingRng::new(inner, 10, rsdr);

        // this will repeat, because it gets reseeded very regularly.
        let s: String = rng.gen_ascii_chars().take(100).collect();
        println!("{}", s);
    }

## Required Methods

### `fn reseed(&mut self, rng: &mut R)`

Reseed the given RNG.

## Implementors

- `impl<R: Rng + Default> Reseeder<R> for ReseedWithDefault`

# Help

## Keyboard Shortcuts

?
  Show this help dialog
S
  Focus the search field
⇤
  Move up in search results
⇥
  Move down in search results
⏎
  Go to active search result
+
  Collapse/expand all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g. `vec -> usize` or `* -> vec`)