Skip to main content

StrictAdd

Trait StrictAdd 

Source
pub trait StrictAdd: Sized {
    type Output;

    // Required method
    fn strict_add(self, v: Self) -> Self::Output;
}
Expand description

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

Required Associated Types§

Source

type Output

The result type (Self for the primitive impls).

Required Methods§

Source

fn strict_add(self, v: Self) -> 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§

type Output = i8

Source§

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

Source§

impl StrictAdd for i16

Source§

type Output = i16

Source§

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

Source§

impl StrictAdd for i32

Source§

type Output = i32

Source§

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

Source§

impl StrictAdd for i64

Source§

type Output = i64

Source§

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

Source§

impl StrictAdd for i128

Source§

type Output = i128

Source§

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

Source§

impl StrictAdd for isize

Source§

type Output = isize

Source§

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

Source§

impl StrictAdd for u8

Source§

type Output = u8

Source§

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

Source§

impl StrictAdd for u16

Source§

type Output = u16

Source§

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

Source§

impl StrictAdd for u32

Source§

type Output = u32

Source§

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

Source§

impl StrictAdd for u64

Source§

type Output = u64

Source§

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

Source§

impl StrictAdd for u128

Source§

type Output = u128

Source§

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

Source§

impl StrictAdd for usize

Source§

type Output = usize

Source§

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

Implementors§