Trait sprs_rand::rand_distr::weighted::alias_method::Weight
source · [−]pub trait Weight: Copy + SampleUniform + PartialOrd<Self> + Add<Self, Output = Self> + AddAssign<Self> + Sub<Self, Output = Self> + SubAssign<Self> + Mul<Self, Output = Self> + MulAssign<Self> + Div<Self, Output = Self> + DivAssign<Self> + Sum<Self> {
const MAX: Self;
const ZERO: Self;
fn try_from_u32_lossy(n: u32) -> Option<Self>;
fn sum(values: &[Self]) -> Self { ... }
}
Expand description
Trait that must be implemented for weights, that are used with
WeightedIndex
. Currently no guarantees on the correctness of
WeightedIndex
are given for custom implementations of this trait.
Required Associated Constants
Required Methods
fn try_from_u32_lossy(n: u32) -> Option<Self>
fn try_from_u32_lossy(n: u32) -> Option<Self>
Produce an instance of Self
from a u32
value, or return None
if
out of range. Loss of precision (where Self
is a floating point type)
is acceptable.