Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extern crate rand;
- use rand::{thread_rng, Rng};
- fn main() {
- let values = create_random_points(10, 10);
- println!("{:?}", values);
- }
- fn create_random_points(x: usize, y: usize) -> Vec<(usize, usize)> {
- let mut points: Vec<(usize, usize)> = vec![];
- for _x in 0..x {
- for _y in 0..y {
- points.push((_x, _y));
- }
- }
- let mut rng = thread_rng();
- let slice = points.as_mut_slice();
- rng.shuffle(slice);
- slice.to_vec()
- }
Add Comment
Please, Sign In to add comment