SHARE
TWEET

Untitled

a guest Jun 19th, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. use itertools::Itertools;
  2. use rand::{distributions::Uniform, Rng}; // 0.6.5
  3.  
  4. fn main() {
  5.     let mut rng = rand::thread_rng();
  6.     let range = Uniform::new(0, 20);
  7.  
  8.     // we stop at 1000 try, use std::iter::repeat(()) if you want infinite
  9.     let vals: Vec<u64> = (0..1000)
  10.         .map(|_| rng.sample(&range))
  11.         .unique()
  12.         .take(100)
  13.         .collect();
  14.  
  15.     println!("{:?}", vals);
  16. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top