[][src]Function turtle::rand::shuffle

pub fn shuffle<S: RandomSlice>(slice: &mut S)

Shuffle the elements of the given slice in place.

None of the elements are modified during this process, only moved.

Example

use turtle::{color, rand::shuffle};

let mut pen_colors = [color::RED, color::BLUE, color::GREEN, color::YELLOW];
// A different order of colors every time!
shuffle(&mut pen_colors);

// Even works with Vec
let mut pen_colors = vec![color::RED, color::BLUE, color::GREEN, color::YELLOW];
shuffle(&mut pen_colors);