File tree 3 files changed +26
-1
lines changed
3 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
7
7
## [ Unreleased]
8
8
- Add ` Lcg128CmDxsm64 ` generator compatible with NumPy's ` PCG64DXSM ` (#1202 )
9
+ - Add examples for initializing the RNGs
9
10
10
11
## [ 0.3.1] - 2021-06-15
11
12
- Add ` advance ` methods to RNGs (#1111 )
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ rand_core = { path = "../rand_core", version = "0.7.0" }
26
26
serde = { version = " 1" , features = [" derive" ], optional = true }
27
27
28
28
[dev-dependencies ]
29
+ rand = { path = " .." , version = " 0.9" }
29
30
# This is for testing serde, unfortunately we can't specify feature-gated dev
30
31
# deps yet, see: https://github.com/rust-lang/cargo/issues/1596
31
32
# Versions prior to 1.1.4 had incorrect minimal dependencies.
Original file line number Diff line number Diff line change 1
- // Copyright 2018 Developers of the Rand project.
1
+ // Copyright 2018-2023 Developers of the Rand project.
2
2
//
3
3
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
4
4
// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
27
27
//! Both of these use 16 bytes of state and 128-bit seeds, and are considered
28
28
//! value-stable (i.e. any change affecting the output given a fixed seed would
29
29
//! be considered a breaking change to the crate).
30
+ //!
31
+ //! # Example
32
+ //!
33
+ //! To initialize a generator, use the [`SeedableRng`][rand_core::SeedableRng] trait:
34
+ //!
35
+ //! ```
36
+ //! use rand_core::{SeedableRng, RngCore};
37
+ //! use rand_pcg::Pcg64Mcg;
38
+ //!
39
+ //! let mut rng = Pcg64Mcg::seed_from_u64(0);
40
+ //! let x: u32 = rng.next_u32();
41
+ //! ```
42
+ //!
43
+ //! The functionality of this crate is implemented using traits from the `rand_core` crate, but you may use the `rand`
44
+ //! crate for further functionality to initialize the generator from various sources and to generate random values:
45
+ //!
46
+ //! ```
47
+ //! use rand::{Rng, SeedableRng};
48
+ //! use rand_pcg::Pcg64Mcg;
49
+ //!
50
+ //! let mut rng = Pcg64Mcg::from_entropy();
51
+ //! let x: f64 = rng.gen();
52
+ //! ```
30
53
31
54
#![ doc(
32
55
html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk.png" ,
You can’t perform that action at this time.
0 commit comments