rand::distr

Trait Weight

Source
pub trait Weight: Clone {
    const ZERO: Self;

    // Required method
    fn checked_add_assign(&mut self, v: &Self) -> Result<(), ()>;
}
Expand description

Bounds on a weight

See usage in WeightedIndex.

Required Associated Constants§

Source

const ZERO: Self

Representation of 0

Required Methods§

Source

fn checked_add_assign(&mut self, v: &Self) -> Result<(), ()>

Checked addition

  • Result::Ok: On success, v is added to self
  • Result::Err: Returns an error when Self cannot represent the result of self + v (i.e. overflow). The value of self should be discarded.

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 Weight for f32

Source§

const ZERO: Self = 0f32

Source§

fn checked_add_assign(&mut self, v: &Self) -> Result<(), ()>

Source§

impl Weight for f64

Source§

const ZERO: Self = 0f64

Source§

fn checked_add_assign(&mut self, v: &Self) -> Result<(), ()>

Source§

impl Weight for i8

Source§

const ZERO: Self = 0i8

Source§

fn checked_add_assign(&mut self, v: &Self) -> Result<(), ()>

Source§

impl Weight for i16

Source§

const ZERO: Self = 0i16

Source§

fn checked_add_assign(&mut self, v: &Self) -> Result<(), ()>

Source§

impl Weight for i32

Source§

const ZERO: Self = 0i32

Source§

fn checked_add_assign(&mut self, v: &Self) -> Result<(), ()>

Source§

impl Weight for i64

Source§

const ZERO: Self = 0i64

Source§

fn checked_add_assign(&mut self, v: &Self) -> Result<(), ()>

Source§

impl Weight for i128

Source§

const ZERO: Self = 0i128

Source§

fn checked_add_assign(&mut self, v: &Self) -> Result<(), ()>

Source§

impl Weight for isize

Source§

const ZERO: Self = 0isize

Source§

fn checked_add_assign(&mut self, v: &Self) -> Result<(), ()>

Source§

impl Weight for u8

Source§

const ZERO: Self = 0u8

Source§

fn checked_add_assign(&mut self, v: &Self) -> Result<(), ()>

Source§

impl Weight for u16

Source§

const ZERO: Self = 0u16

Source§

fn checked_add_assign(&mut self, v: &Self) -> Result<(), ()>

Source§

impl Weight for u32

Source§

const ZERO: Self = 0u32

Source§

fn checked_add_assign(&mut self, v: &Self) -> Result<(), ()>

Source§

impl Weight for u64

Source§

const ZERO: Self = 0u64

Source§

fn checked_add_assign(&mut self, v: &Self) -> Result<(), ()>

Source§

impl Weight for u128

Source§

const ZERO: Self = 0u128

Source§

fn checked_add_assign(&mut self, v: &Self) -> Result<(), ()>

Source§

impl Weight for usize

Source§

const ZERO: Self = 0usize

Source§

fn checked_add_assign(&mut self, v: &Self) -> Result<(), ()>

Implementors§