num_traits::ops::checked

Trait CheckedSub

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

Performs subtraction that returns None instead of wrapping around on underflow.

Required Methods§

Source

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

Subtracts two numbers, checking for underflow. If underflow happens, None is returned.

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, v: &i8) -> Option<i8>

Source§

impl CheckedSub for i16

Source§

fn checked_sub(&self, v: &i16) -> Option<i16>

Source§

impl CheckedSub for i32

Source§

fn checked_sub(&self, v: &i32) -> Option<i32>

Source§

impl CheckedSub for i64

Source§

fn checked_sub(&self, v: &i64) -> Option<i64>

Source§

impl CheckedSub for i128

Source§

fn checked_sub(&self, v: &i128) -> Option<i128>

Source§

impl CheckedSub for isize

Source§

fn checked_sub(&self, v: &isize) -> Option<isize>

Source§

impl CheckedSub for u8

Source§

fn checked_sub(&self, v: &u8) -> Option<u8>

Source§

impl CheckedSub for u16

Source§

fn checked_sub(&self, v: &u16) -> Option<u16>

Source§

impl CheckedSub for u32

Source§

fn checked_sub(&self, v: &u32) -> Option<u32>

Source§

impl CheckedSub for u64

Source§

fn checked_sub(&self, v: &u64) -> Option<u64>

Source§

impl CheckedSub for u128

Source§

fn checked_sub(&self, v: &u128) -> Option<u128>

Source§

impl CheckedSub for usize

Source§

fn checked_sub(&self, v: &usize) -> Option<usize>

Implementors§