diff options
| author | bors <bors@rust-lang.org> | 2014-07-19 23:26:37 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-07-19 23:26:37 +0000 |
| commit | d8652de94231114f96e022cdb84ce31490874ea9 (patch) | |
| tree | 7028c526a2114f8e6e230aee218069a07bbc3092 /src/libstd | |
| parent | 8672a235dd5b4677a6ff0ede1e3ce39b076b5414 (diff) | |
| parent | c8b8444ce131798b94e759138bb307144ed0994f (diff) | |
| download | rust-d8652de94231114f96e022cdb84ce31490874ea9.tar.gz rust-d8652de94231114f96e022cdb84ce31490874ea9.zip | |
auto merge of #15746 : steveklabnik/rust/docs_random, r=alexcrichton
This is now linked to in the guide, so I want to make sure it's good. This adds a bit more explanation, and brings usage in line with current good style.
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/rand/mod.rs | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/src/libstd/rand/mod.rs b/src/libstd/rand/mod.rs index 0ffaadef0a1..a9b9a907a26 100644 --- a/src/libstd/rand/mod.rs +++ b/src/libstd/rand/mod.rs @@ -226,19 +226,24 @@ impl Rng for TaskRng { } } -/// Generate a random value using the task-local random number -/// generator. +/// Generates a random value using the task-local random number generator. /// -/// # Example +/// `random()` can generate various types of random things, and so may require +/// type hinting to generate the specific type you want. +/// +/// # Examples /// /// ```rust -/// use std::rand::random; +/// use std::rand; +/// +/// let x = rand::random(); +/// println!("{}", 2u * x); +/// +/// let y = rand::random::<f64>(); +/// println!("{}", y); /// -/// if random() { -/// let x = random(); -/// println!("{}", 2u * x); -/// } else { -/// println!("{}", random::<f64>()); +/// if rand::random() { // generates a boolean +/// println!("Better lucky than good!"); /// } /// ``` #[inline] |
