shuffle

Crates.ioshuffle
lib.rsshuffle
version0.2.1
created_at2019-10-01 17:33:26.105251+00
updated_at2025-12-04 21:07:26.34069+00
descriptionImplementation of various shuffling algorithms over slices.
homepage
repositoryhttps://github.com/adambudziak/shuffle
max_upload_size
id169150
size20,527
Adam Budziak (adambudziak)

documentation

https://docs.rs/shuffle

README

shuffle

Various shuffling algorithms for rust.

Currently implemented shuffling algorithms

  • Inverse Riffle Shuffle
  • Fisher-Yates
  • ... ? TODO

no_std Support

This crate is no_std compatible but requires the alloc crate (for Vec).

Examples

use shuffle::shuffler::Shuffler;
use shuffle::irs::Irs;
use rand::rngs::mock::StepRng;

let mut rng = StepRng::new(2, 13);
let mut irs = Irs::default();
let mut input = vec![1, 2, 3, 4, 5];

irs.shuffle(&mut input, &mut rng);
assert_eq!(&input, &[4, 1, 5, 3, 2]);
Commit count: 0

cargo fmt