title: How to create a random sample from a vector of elements?
body: <p>I used this code to create a random sample for the numbers 0 to 49. Now I want to create a random sample for a custom set of values. For example: select a sample of 5 from <code>[1, 2, 3, 4, 9, 10, 11, 14, 16, 22, 32, 45]</code>. How can I do this?</p>
  
  <pre><code>use rand::{seq, thread_rng}; // 0.7.3
  
  fn main() {
      let mut rng = thread_rng();
      let sample = seq::index::sample(&amp;mut rng, 50, 5);
  }
  </code></pre>