Skip to main content

Weight

Trait Weight 

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§

const ZERO: Self

Representation of 0

Required Methods§

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§

§

impl Weight for f32

§

const ZERO: f32 = 0.0

§

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

§

impl Weight for f64

§

const ZERO: f64 = 0.0

§

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

§

impl Weight for i8

§

const ZERO: i8 = 0

§

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

§

impl Weight for i16

§

const ZERO: i16 = 0

§

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

§

impl Weight for i32

§

const ZERO: i32 = 0

§

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

§

impl Weight for i64

§

const ZERO: i64 = 0

§

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

§

impl Weight for i128

§

const ZERO: i128 = 0

§

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

§

impl Weight for isize

§

const ZERO: isize = 0

§

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

§

impl Weight for u8

§

const ZERO: u8 = 0

§

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

§

impl Weight for u16

§

const ZERO: u16 = 0

§

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

§

impl Weight for u32

§

const ZERO: u32 = 0

§

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

§

impl Weight for u64

§

const ZERO: u64 = 0

§

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

§

impl Weight for u128

§

const ZERO: u128 = 0

§

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

§

impl Weight for usize

§

const ZERO: usize = 0

§

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

Implementors§