title: How can I get a random number in Rust 1.0?
body: <p>I tried</p>
  
  <pre><code>use std::rand::{task_rng, Rng};
  
  fn main() {
      // a number from [-40.0, 13000.0)
      let num: f64 = task_rng().gen_range(-40.0, 1.3e4);
      println!("{}", num);
  }
  </code></pre>
  
  <p>but this gives</p>
  
  <pre class="lang-none prettyprint-override"><code>error[E0432]: unresolved import `std::rand::task_rng`
   --&gt; rand.rs:1:17
    |
  1 | use std::rand::{task_rng, Rng};
    |                 ^^^^^^^^ no `task_rng` in `rand`
  
  error[E0432]: unresolved import `std::rand::Rng`
   --&gt; rand.rs:1:27
    |
  1 | use std::rand::{task_rng, Rng};
    |                           ^^^ no `Rng` in `rand`
  
  error[E0603]: module `rand` is private
   --&gt; rand.rs:1:17
    |
  1 | use std::rand::{task_rng, Rng};
    |                 ^^^^^^^^
  
  error[E0603]: module `rand` is private
   --&gt; rand.rs:1:27
    |
  1 | use std::rand::{task_rng, Rng};
    |                           ^^^
  </code></pre>
  
  <p>and I tried</p>
  
  <pre><code>extern crate rand;
  use rand::Rng;
  
  fn main() {
      let mut rng = rand::thread_rng();
      if rng.gen() {
          // random bool
          println!("i32: {}, u32: {}", rng.gen::&lt;i32&gt;(), rng.gen::&lt;u32&gt;())
      }
      let tuple = rand::random::&lt;(f64, char)&gt;();
      println!("{:?}", tuple)
  }
  </code></pre>
  
  <p>and got</p>
  
  <pre class="lang-none prettyprint-override"><code>error[E0425]: cannot find function `thread_rng` in module `rand`
   --&gt; rand.rs:5:29
    |
  5 |         let mut rng = rand::thread_rng();
    |                             ^^^^^^^^^^ not found in `rand`
    |
  help: possible candidate is found in another module, you can import it into scope
    |     use std::__rand::thread_rng;
  
  error[E0425]: cannot find function `random` in module `rand`
    --&gt; rand.rs:10:27
     |
  10 |         let tuple = rand::random::&lt;(f64, char)&gt;();
     |                           ^^^^^^ not found in `rand`
  
  error: use of unstable library feature 'rand': use `rand` from crates.io (see issue #27703)
   --&gt; rand.rs:1:5
    |
  1 |     extern crate rand;
    |     ^^^^^^^^^^^^^^^^^^
  
  error: use of unstable library feature 'rand': use `rand` from crates.io (see issue #27703)
   --&gt; rand.rs:2:9
    |
  2 |     use rand::Rng;
    |         ^^^^^^^^^
  </code></pre>