Skip to content

Commit

Permalink
Add example for initializing a PCG RNG (#1347)
Browse files Browse the repository at this point in the history
  • Loading branch information
vks committed Oct 30, 2023
1 parent d0499f0 commit d9a89c8
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion rand_pcg/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 Developers of the Rand project.
// Copyright 2018-2023 Developers of the Rand project.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
Expand Down Expand Up @@ -27,6 +27,18 @@
//! Both of these use 16 bytes of state and 128-bit seeds, and are considered
//! value-stable (i.e. any change affecting the output given a fixed seed would
//! be considered a breaking change to the crate).
//!
//! # Example
//!
//! To initialize a generator, use the [`SeedableRng`][rand_core::SeedableRng] trait:
//!
//! ```rust
//! use rand::{SeedableRng, Rng};
//! use rand_pcg::Pcg64Mcg;
//!
//! let mut rng = Pcg64Mcg::from_entropy();
//! let x: u32 = rng.gen();
//! ```

#![doc(
html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk.png",
Expand Down

0 comments on commit d9a89c8

Please sign in to comment.