Skip to main content

CheckedSubUnsigned

Trait CheckedSubUnsigned 

Source
pub trait CheckedSubUnsigned: Sized {
    type Unsigned;
    type Output;

    // Required method
    fn checked_sub_unsigned(self, rhs: Self::Unsigned) -> Option<Self::Output>;
}
Expand description

Checked subtraction of an unsigned value from a signed value.

Required Associated Types§

Source

type Unsigned

The counterpart type of opposite signedness.

Source

type Output

The (owned) result type.

Required Methods§

Source

fn checked_sub_unsigned(self, rhs: Self::Unsigned) -> Option<Self::Output>

Computes self - rhs, returning None if overflow occurred.

use const_num_traits::CheckedSubUnsigned;

assert_eq!(CheckedSubUnsigned::checked_sub_unsigned(1i8, 2), Some(-1));
assert_eq!(CheckedSubUnsigned::checked_sub_unsigned(i8::MIN, 1), None);

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

Source§

impl CheckedSubUnsigned for i16

Source§

impl CheckedSubUnsigned for i32

Source§

impl CheckedSubUnsigned for i64

Source§

impl CheckedSubUnsigned for i128

Source§

impl CheckedSubUnsigned for isize

Implementors§