/// Shuffle a mutable slice.
///
/// This is an implementation of the Fisher-Yates algorithm.
/// I know this exact same algorithm is implemented in std, but I created this
/// project to practice Rust, so why not just write more code.
Shuffle a mutable slice.
This is an implementation of the Fisher-Yates algorithm.
I know this exact same algorithm is implemented in std, but I created this
project to practice Rust, so why not just write more code.
Shuffle a mutable slice . This is an implementation of the Fisher - Yates algorithm . I know this exact same algorithm is implemented in std but I created this project to practice Rust so why not just write more code .
fn shuffle<T>(v: &mut [T]) {
  let mut rng = thread_rng();
  let mut i: usize = v.len() - 1;
  while i > 0 {
    let j: usize = rng.gen_range(0, i+1);
    v.swap(i, j);
    i = i - 1;
  }
}
fn shuffle < T > ( v : & mut [ T ] ) { let mut rng = thread_rng ( ) ; let mut i : usize = v . len ( ) - 1 ; while i > 0 { let j : usize = rng . gen_range ( 0 , i + 1 ) ; v . swap ( i , j ) ; i = i - 1 ; } }
Shuffle a mutable slice.
Shuffle a mutable slice .
v
&mut [T]