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§
Required Methods§
Sourcefn checked_add_assign(&mut self, v: &Self) -> Result<(), ()>
fn checked_add_assign(&mut self, v: &Self) -> Result<(), ()>
Checked addition
Result::Ok
: On success,v
is added toself
Result::Err
: Returns an error whenSelf
cannot represent the result ofself + v
(i.e. overflow). The value ofself
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.