about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorSteve Klabnik <steve@steveklabnik.com>2014-07-17 11:59:45 -0400
committerSteve Klabnik <steve@steveklabnik.com>2014-07-18 21:19:51 -0400
commitc8b8444ce131798b94e759138bb307144ed0994f (patch)
treeb912c72d1fe0ba2e6a9c7c6c231f179dc2a9f3c9 /src/libstd
parentdd348b3ab0147fda3dedbdc6947c14354971e14a (diff)
Improve documentation for rand::random
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]