Skip to content

Commit 0f25f7e

Browse files
authored
Merge pull request #45 from vks/quickstart-examples
Quickstart examples
2 parents 73da25c + f707649 commit 0f25f7e

File tree

4 files changed

+36
-5
lines changed

4 files changed

+36
-5
lines changed

rand_hc/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,15 @@
77
// except according to those terms.
88

99
//! The HC128 random number generator.
10+
//!
11+
//! To initialize a generator, use the [`SeedableRng`][rand_core::SeedableRng] trait.
1012
1113
#![doc(
1214
html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk.png",
1315
html_favicon_url = "https://www.rust-lang.org/favicon.ico",
1416
html_root_url = "https://rust-random.github.io/rand/"
1517
)]
18+
#![forbid(unsafe_code)]
1619
#![deny(missing_docs)]
1720
#![deny(missing_debug_implementations)]
1821
#![doc(test(attr(allow(unused_variables), deny(warnings))))]

rand_isaac/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2018 Developers of the Rand project.
1+
// Copyright 2018-2023 Developers of the Rand project.
22
//
33
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
44
// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
@@ -7,6 +7,8 @@
77
// except according to those terms.
88

99
//! The ISAAC and ISAAC-64 random number generators.
10+
//!
11+
//! To initialize a generator, use the [`SeedableRng`][rand_core::SeedableRng] trait.
1012
1113
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk.png",
1214
html_favicon_url = "https://www.rust-lang.org/favicon.ico",

rand_xorshift/src/lib.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2018 Developers of the Rand project.
1+
// Copyright 2018-2023 Developers of the Rand project.
22
//
33
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
44
// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
@@ -7,11 +7,24 @@
77
// except according to those terms.
88

99
//! The xorshift random number generator.
10+
//!
11+
//! # Example
12+
//!
13+
//! To initialize a generator, use the [`SeedableRng`][rand_core::SeedableRng] trait:
14+
//!
15+
//! ```
16+
//! use rand_core::{SeedableRng, RngCore};
17+
//! use rand_xorshift::XorShiftRng;
18+
//!
19+
//! let mut rng = XorShiftRng::seed_from_u64(0);
20+
//! let x = rng.next_u32();
21+
//! ```
1022
1123
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk.png",
1224
html_favicon_url = "https://www.rust-lang.org/favicon.ico",
1325
html_root_url = "https://docs.rs/rand_xorshift/0.3.0")]
1426

27+
#![forbid(unsafe_code)]
1528
#![deny(missing_docs)]
1629
#![deny(missing_debug_implementations)]
1730

rand_xoshiro/src/lib.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2018 Developers of the Rand project.
1+
// Copyright 2018-2023 Developers of the Rand project.
22
//
33
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
44
// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
@@ -8,7 +8,7 @@
88

99
//! This crate implements the [xoshiro] family of pseudorandom number generators
1010
//! designed by David Blackman and Sebastiano Vigna. They feature high
11-
//! perfomance and a small state and supersede the previous xorshift-based
11+
//! performance and a small state and supersede the previous xorshift-based
1212
//! generators. However, they are not cryptographically secure and their output
1313
//! can be predicted by observing a few samples.
1414
//!
@@ -61,9 +61,21 @@
6161
//! lowest bits (which are discarded when generating floats), making it fail
6262
//! linearity tests. This is unlikely to have any impact in practise.
6363
//!
64-
//! The `*PlusPlus` generators perform similarily to the `*StarStar` generators.
64+
//! The `*PlusPlus` generators perform similarly to the `*StarStar` generators.
6565
//! See the [xoshiro paper], where the differences are discussed in detail.
6666
//!
67+
//! # Example
68+
//!
69+
//! To initialize a generator, use the [`SeedableRng`][rand_core::SeedableRng] trait:
70+
//!
71+
//! ```
72+
//! use rand_core::{SeedableRng, RngCore};
73+
//! use rand_xoshiro::Xoshiro256PlusPlus;
74+
//!
75+
//! let mut rng = Xoshiro256PlusPlus::seed_from_u64(0);
76+
//! let x = rng.next_u64();
77+
//! ```
78+
//!
6779
//! [xoshiro]: http://xoshiro.di.unimi.it/
6880
//! [xoshiro paper]: http://vigna.di.unimi.it/ftp/papers/ScrambledLinear.pdf
6981
//! [low linear complexity]: http://xoshiro.di.unimi.it/lowcomp.php
@@ -72,6 +84,7 @@
7284
html_favicon_url = "https://www.rust-lang.org/favicon.ico",
7385
html_root_url = "https://docs.rs/rand_xoshiro/0.6.0")]
7486

87+
#![forbid(unsafe_code)]
7588
#![deny(missing_docs)]
7689
#![deny(missing_debug_implementations)]
7790
#![allow(clippy::unreadable_literal)]

0 commit comments

Comments
 (0)