Skip to main content

CheckedSubSigned

Trait CheckedSubSigned 

Source
pub trait CheckedSubSigned: Sized {
    type Signed;
    type Output;

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

Checked subtraction of a signed value from an unsigned value.

Required Associated Types§

Source

type Signed

The counterpart type of opposite signedness.

Source

type Output

The (owned) result type.

Required Methods§

Source

fn checked_sub_signed(self, rhs: Self::Signed) -> Option<Self::Output>

Computes self - rhs, returning None if overflow occurred.

use const_num_traits::CheckedSubSigned;

assert_eq!(CheckedSubSigned::checked_sub_signed(1u8, 2), None);
assert_eq!(CheckedSubSigned::checked_sub_signed(1u8, -2), Some(3));

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 CheckedSubSigned for u8

Source§

impl CheckedSubSigned for u16

Source§

impl CheckedSubSigned for u32

Source§

impl CheckedSubSigned for u64

Source§

impl CheckedSubSigned for u128

Source§

impl CheckedSubSigned for usize

Implementors§