sample_single_excluding

Function sample_single_excluding 

Source
pub fn sample_single_excluding<'a, R, T, E>(
    rng: &mut R,
    slice: &'a [T],
    excluded: E,
) -> Option<&'a T>
where R: Rng, T: PartialEq, E: Borrow<T>,
Expand description

Samples one element uniformly at random from slice, excluding any element equal to excluded. Returns None if the slice is empty or every element equals excluded.

excluded accepts either an owned T or a borrowed &T via the Borrow<T> bound. Dispatches to sample_single_excluding_iteration for slices of length < 4 and sample_single_excluding_rejection otherwise. Tuned via ixa-bench/criterion/sample_single_excluding.rs.