Skip to main content

StrictAdd

Trait StrictAdd 

Source
pub trait StrictAdd: Sized + Add<Self> {
    // Required method
    fn strict_add(self, v: Self) -> <Self as Add<Self>>::Output;
}
Expand description

Performs addition that panics on overflow, even in release builds.

Required Methods§

Source

fn strict_add(self, v: Self) -> <Self as Add<Self>>::Output

Strict addition. Computes self + v, panicking on overflow regardless of whether overflow checks are enabled.

use const_num_traits::StrictAdd;

assert_eq!(StrictAdd::strict_add(5u8, 250), 255);

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl StrictAdd for i8

Source§

fn strict_add(self, v: Self) -> Self

Source§

impl StrictAdd for i16

Source§

fn strict_add(self, v: Self) -> Self

Source§

impl StrictAdd for i32

Source§

fn strict_add(self, v: Self) -> Self

Source§

impl StrictAdd for i64

Source§

fn strict_add(self, v: Self) -> Self

Source§

impl StrictAdd for i128

Source§

fn strict_add(self, v: Self) -> Self

Source§

impl StrictAdd for isize

Source§

fn strict_add(self, v: Self) -> Self

Source§

impl StrictAdd for u8

Source§

fn strict_add(self, v: Self) -> Self

Source§

impl StrictAdd for u16

Source§

fn strict_add(self, v: Self) -> Self

Source§

impl StrictAdd for u32

Source§

fn strict_add(self, v: Self) -> Self

Source§

impl StrictAdd for u64

Source§

fn strict_add(self, v: Self) -> Self

Source§

impl StrictAdd for u128

Source§

fn strict_add(self, v: Self) -> Self

Source§

impl StrictAdd for usize

Source§

fn strict_add(self, v: Self) -> Self

Implementors§