pub trait IndexedMutRandom: IndexedRandom + IndexMut<usize> {
    // Provided methods
    fn choose_mut<R>(&mut self, rng: &mut R) -> Option<&mut Self::Output>
       where R: Rng + ?Sized { ... }
    fn choose_weighted_mut<R, F, B, X>(
        &mut self,
        rng: &mut R,
        weight: F,
    ) -> Result<&mut Self::Output, Error>
       where R: Rng + ?Sized,
             F: Fn(&Self::Output) -> B,
             B: SampleBorrow<X>,
             X: SampleUniform + Weight + PartialOrd { ... }
}Expand description
Extension trait on indexable lists, providing random sampling methods.
This trait is implemented automatically for every type implementing
IndexedRandom and std::ops::IndexMut<usize>.
Provided Methods§
Sourcefn choose_mut<R>(&mut self, rng: &mut R) -> Option<&mut Self::Output>
 
fn choose_mut<R>(&mut self, rng: &mut R) -> Option<&mut Self::Output>
Uniformly sample one element (mut)
Returns a mutable reference to one uniformly-sampled random element of
the slice, or None if the slice is empty.
For slices, complexity is O(1).
Sourcefn choose_weighted_mut<R, F, B, X>(
    &mut self,
    rng: &mut R,
    weight: F,
) -> Result<&mut Self::Output, Error>where
    R: Rng + ?Sized,
    F: Fn(&Self::Output) -> B,
    B: SampleBorrow<X>,
    X: SampleUniform + Weight + PartialOrd,
 
fn choose_weighted_mut<R, F, B, X>(
    &mut self,
    rng: &mut R,
    weight: F,
) -> Result<&mut Self::Output, Error>where
    R: Rng + ?Sized,
    F: Fn(&Self::Output) -> B,
    B: SampleBorrow<X>,
    X: SampleUniform + Weight + PartialOrd,
Biased sampling for one element (mut)
Returns a mutable reference to one element of the slice, sampled according
to the provided weights. Returns None only if the slice is empty.
The specified function weight maps each item x to a relative
likelihood weight(x). The probability of each item being selected is
therefore weight(x) / s, where s is the sum of all weight(x).
For slices of length n, complexity is O(n).
For more information about the underlying algorithm,
see the WeightedIndex distribution.
See also choose_weighted.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.