title: How do I create a random String by sampling from alphanumeric characters?
body: <p>I tried to compile the following code:</p>
  
  <pre><code>extern crate rand; // 0.6
  use rand::Rng;
  
  fn main() {
      rand::thread_rng()
          .gen_ascii_chars()
          .take(10)
          .collect::&lt;String&gt;();
  }
  </code></pre>
  
  <p>but <code>cargo build</code> says:</p>
  
  <pre class="lang-none prettyprint-override"><code>warning: unused import: `rand::Rng`
   --&gt; src/main.rs:2:5
    |
  2 | use rand::Rng;
    |     ^^^^^^^^^
    |
    = note: #[warn(unused_imports)] on by default
  
  error[E0599]: no method named `gen_ascii_chars` found for type `rand::prelude::ThreadRng` in the current scope
   --&gt; src/main.rs:6:10
    |
  6 |         .gen_ascii_chars()
    |          ^^^^^^^^^^^^^^^
  </code></pre>
  
  <p>The Rust compiler asks me to remove the <code>use rand::Rng;</code> clause, at the same time complaining that there is no <code>gen_ascii_chars</code> method. 
  I would expect Rust to just use <code>rand::Rng</code> trait, and to not provide such a contradictory error messages. How can I go further from here?</p>