shuffle

Function shuffle 

Source
pub fn shuffle<T: Clone>(list: &[T]) -> Vec<T>
Expand description

Shuffles a slice of generic type T using the Fisher-Yates shuffle algorithm.

§Arguments

  • list - A slice of generic type T to be shuffled.

§Returns

A new Vec<T> that is a shuffled version of the input slice.

§Examples

let list = vec![1, 2, 3, 4, 5];

let shuffled_list = shufflr::shuffle(&list);

assert_ne!(list, shuffled_list);