AliasableWeight

Trait AliasableWeight 

Source
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;

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

    // Provided method
    fn sum(values: &[Self]) -> Self { ... }
}
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.

Required Associated Constants§

Source

const MAX: Self

Maximum number representable by Self.

Source

const ZERO: Self

Element of Self equivalent to 0.

Required Methods§

Source

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.

Provided Methods§

Source

fn sum(values: &[Self]) -> Self

Sums all values in slice values.

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.

Implementations on Foreign Types§

Source§

impl AliasableWeight for f32

Source§

const MAX: Self = ::core::f32::MAX

Source§

const ZERO: Self = 0.0

Source§

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

Source§

fn sum(values: &[Self]) -> Self

Source§

impl AliasableWeight for f64

Source§

const MAX: Self = ::core::f64::MAX

Source§

const ZERO: Self = 0.0

Source§

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

Source§

fn sum(values: &[Self]) -> Self

Source§

impl AliasableWeight for i8

Source§

const MAX: Self = ::core::i8::MAX

Source§

const ZERO: Self = 0

Source§

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

Source§

impl AliasableWeight for i16

Source§

const MAX: Self = ::core::i16::MAX

Source§

const ZERO: Self = 0

Source§

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

Source§

impl AliasableWeight for i32

Source§

const MAX: Self = ::core::i32::MAX

Source§

const ZERO: Self = 0

Source§

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

Source§

impl AliasableWeight for i64

Source§

const MAX: Self = ::core::i64::MAX

Source§

const ZERO: Self = 0

Source§

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

Source§

impl AliasableWeight for i128

Source§

const MAX: Self = ::core::i128::MAX

Source§

const ZERO: Self = 0

Source§

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

Source§

impl AliasableWeight for isize

Source§

const MAX: Self = ::core::isize::MAX

Source§

const ZERO: Self = 0

Source§

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

Source§

impl AliasableWeight for u8

Source§

const MAX: Self = ::core::u8::MAX

Source§

const ZERO: Self = 0

Source§

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

Source§

impl AliasableWeight for u16

Source§

const MAX: Self = ::core::u16::MAX

Source§

const ZERO: Self = 0

Source§

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

Source§

impl AliasableWeight for u32

Source§

const MAX: Self = ::core::u32::MAX

Source§

const ZERO: Self = 0

Source§

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

Source§

impl AliasableWeight for u64

Source§

const MAX: Self = ::core::u64::MAX

Source§

const ZERO: Self = 0

Source§

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

Source§

impl AliasableWeight for u128

Source§

const MAX: Self = ::core::u128::MAX

Source§

const ZERO: Self = 0

Source§

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

Source§

impl AliasableWeight for usize

Source§

const MAX: Self = ::core::usize::MAX

Source§

const ZERO: Self = 0

Source§

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

Implementors§