From 369d11587339ce74f8ebc76f2607fe55545eaf7d Mon Sep 17 00:00:00 2001 From: garhve Date: Tue, 20 Dec 2022 11:04:25 +0800 Subject: Build small project following the book --- .../guessing_game/target/doc/rand/index.html | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/index.html (limited to 'rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/index.html') diff --git a/rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/index.html b/rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/index.html new file mode 100644 index 0000000..07aa415 --- /dev/null +++ b/rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/index.html @@ -0,0 +1,33 @@ +rand - Rust

Crate rand

source · []
Expand description

Utilities for random number generation

+

Rand provides utilities to generate random numbers, to convert them to +useful types and distributions, and some randomness-related algorithms.

+

Quick Start

+

To get you started quickly, the easiest and highest-level way to get +a random value is to use random(); alternatively you can use +thread_rng(). The Rng trait provides a useful API on all RNGs, while +the distributions and seq modules provide further +functionality on top of RNGs.

+ +
use rand::prelude::*;
+
+if rand::random() { // generates a boolean
+    // Try printing a random unicode code point (probably a bad idea)!
+    println!("char: {}", rand::random::<char>());
+}
+
+let mut rng = rand::thread_rng();
+let y: f64 = rng.gen(); // generates a float between 0 and 1
+
+let mut nums: Vec<i32> = (1..100).collect();
+nums.shuffle(&mut rng);
+

The Book

+

For the user guide and further documentation, please read +The Rust Rand Book.

+

Modules

Generating random samples from probability distributions
Convenience re-export of common members
Random number generators and adapters
Sequence-related functionality

Structs

Error type of random number generators

Traits

A marker trait used to indicate that an RngCore or BlockRngCore +implementation is supposed to be cryptographically secure.
Types which may be filled with random data
An automatically-implemented extension trait on RngCore providing high-level +generic methods for sampling values and other convenience methods.
The core of a random number generator.
A random number generator that can be explicitly seeded.

Functions

Generates a random value using the thread-local random number generator.
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.
\ No newline at end of file -- cgit v1.2.3-70-g09d2