From d9a89c8f13be1db2229a7a02b4a940a121b5a1b8 Mon Sep 17 00:00:00 2001 From: Vinzent Steinberg Date: Mon, 30 Oct 2023 21:24:34 +0100 Subject: [PATCH] Add example for initializing a PCG RNG (#1347) --- rand_pcg/src/lib.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/rand_pcg/src/lib.rs b/rand_pcg/src/lib.rs index 341313954e7..c4228edfc6c 100644 --- a/rand_pcg/src/lib.rs +++ b/rand_pcg/src/lib.rs @@ -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 or the MIT license @@ -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",