logo
pub trait AliasableWeight: Sized + Copy + SampleUniform + PartialOrd + Add<Output = Self> + AddAssign + Sub<Output = Self> + SubAssign + Mul<Output = Self> + MulAssign + Div<Output = Self> + DivAssign + Sum {
    const MAX: Self;
    const ZERO: Self;

    fn try_from_u32_lossy(n: u32) -> Option<Self>;

    fn sum(values: &[Self]) -> Self { ... }
}
This is supported on crate feature alloc only.
Expand description

Trait that must be implemented for weights, that are used with WeightedAliasIndex. Currently no guarantees on the correctness of WeightedAliasIndex are given for custom implementations of this trait.

Associated Constants

Maximum number representable by Self.

Element of Self equivalent to 0.

Required methods

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.

Provided methods

Sums all values in slice values.

Implementations on Foreign Types

Implementors