CheckedSub

Trait CheckedSub 

Source
pub trait CheckedSub: Sub + Sized {
    // Required method
    fn checked_sub(self, rhs: Self) -> Option<Self>;
}
Expand description

Performs checked substraction. Maps directly to the integers checked_sub method. (i.e. u8::checked_sub) Consult the docs of the primitive methods to learn more.

Required Methods§

Source

fn checked_sub(self, rhs: Self) -> Option<Self>

performs checked sub

§Example
let a = 2u8;
let b = 1u8;

assert_eq!(CheckedSub::checked_sub(a, b), a.checked_sub(b));
assert_eq!(CheckedSub::checked_sub(b, a), b.checked_sub(a));

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 CheckedSub for i8

Source§

fn checked_sub(self, rhs: Self) -> Option<Self>

Source§

impl CheckedSub for i16

Source§

fn checked_sub(self, rhs: Self) -> Option<Self>

Source§

impl CheckedSub for i32

Source§

fn checked_sub(self, rhs: Self) -> Option<Self>

Source§

impl CheckedSub for i64

Source§

fn checked_sub(self, rhs: Self) -> Option<Self>

Source§

impl CheckedSub for u8

Source§

fn checked_sub(self, rhs: Self) -> Option<Self>

Source§

impl CheckedSub for u16

Source§

fn checked_sub(self, rhs: Self) -> Option<Self>

Source§

impl CheckedSub for u32

Source§

fn checked_sub(self, rhs: Self) -> Option<Self>

Source§

impl CheckedSub for u64

Source§

fn checked_sub(self, rhs: Self) -> Option<Self>

Implementors§