Function sample_std::choice

source ·
pub fn choice<T, II>(choices: II) -> Choice<T>
where T: Clone + PartialEq, II: IntoIterator<Item = T>,
Expand description

Sample from a list of choice values.

Sample::shrink will attempt to shrink down to the first element in the Choice:

use sample_std::{Random, Sample, choice};

let mut sampler = choice(["cora", "coraline"]);
let name = sampler.generate(&mut Random::new());
assert!(name.starts_with("cora"));

assert_eq!(sampler.shrink("coraline").next(), Some("cora"));