about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-07-19 23:26:37 +0000
committerbors <bors@rust-lang.org>2014-07-19 23:26:37 +0000
commitd8652de94231114f96e022cdb84ce31490874ea9 (patch)
tree7028c526a2114f8e6e230aee218069a07bbc3092 /src/libstd
parent8672a235dd5b4677a6ff0ede1e3ce39b076b5414 (diff)
parentc8b8444ce131798b94e759138bb307144ed0994f (diff)
downloadrust-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.rs23
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]