# thread_rng in rand - Rust
Retrieve the lazily-initialized thread-local random number generator, seeded by the system. Intended to be used in method chaining style, e.g. `thread_rng().gen::<i32>()`, or cached locally, e.g. `let mut rng = thread_rng();`. Invoked by the `Default` trait, making `ThreadRng::default()` equivalent.
Keywords: rust, rustlang, rust-lang, thread_rng

# Function rand::thread_rng

source · [−]

    pub fn thread_rng() -> ThreadRng

Expand description

Retrieve the lazily-initialized thread-local random number generator, seeded by the system. Intended to be used in method chaining style, e.g. `thread_rng().gen::<i32>()`, or cached locally, e.g. `let mut rng = thread_rng();`. Invoked by the `Default` trait, making `ThreadRng::default()` equivalent.

For more information see `ThreadRng`.