Trait num_traits::ops::checked::CheckedRem [−][src]
pub trait CheckedRem: Sized + Rem<Self, Output = Self> { fn checked_rem(&self, v: &Self) -> Option<Self>; }
Performs an integral remainder that returns None
instead of panicking on division by zero and
instead of wrapping around on underflow and overflow.
Required Methods
fn checked_rem(&self, v: &Self) -> Option<Self>
Finds the remainder of dividing two numbers, checking for underflow, overflow and division
by zero. If any of that happens, None
is returned.
Examples
use num_traits::CheckedRem; use std::i32::MIN; assert_eq!(CheckedRem::checked_rem(&10, &7), Some(3)); assert_eq!(CheckedRem::checked_rem(&10, &-7), Some(3)); assert_eq!(CheckedRem::checked_rem(&-10, &7), Some(-3)); assert_eq!(CheckedRem::checked_rem(&-10, &-7), Some(-3)); assert_eq!(CheckedRem::checked_rem(&10, &0), None); assert_eq!(CheckedRem::checked_rem(&MIN, &1), Some(0)); assert_eq!(CheckedRem::checked_rem(&MIN, &-1), None);
Implementations on Foreign Types
impl CheckedRem for u8
[src]
impl CheckedRem for u8
fn checked_rem(&self, v: &u8) -> Option<u8>
[src]
fn checked_rem(&self, v: &u8) -> Option<u8>
impl CheckedRem for u16
[src]
impl CheckedRem for u16
fn checked_rem(&self, v: &u16) -> Option<u16>
[src]
fn checked_rem(&self, v: &u16) -> Option<u16>
impl CheckedRem for u32
[src]
impl CheckedRem for u32
fn checked_rem(&self, v: &u32) -> Option<u32>
[src]
fn checked_rem(&self, v: &u32) -> Option<u32>
impl CheckedRem for u64
[src]
impl CheckedRem for u64
fn checked_rem(&self, v: &u64) -> Option<u64>
[src]
fn checked_rem(&self, v: &u64) -> Option<u64>
impl CheckedRem for usize
[src]
impl CheckedRem for usize
fn checked_rem(&self, v: &usize) -> Option<usize>
[src]
fn checked_rem(&self, v: &usize) -> Option<usize>
impl CheckedRem for u128
[src]
impl CheckedRem for u128
fn checked_rem(&self, v: &u128) -> Option<u128>
[src]
fn checked_rem(&self, v: &u128) -> Option<u128>
impl CheckedRem for i8
[src]
impl CheckedRem for i8
fn checked_rem(&self, v: &i8) -> Option<i8>
[src]
fn checked_rem(&self, v: &i8) -> Option<i8>
impl CheckedRem for i16
[src]
impl CheckedRem for i16
fn checked_rem(&self, v: &i16) -> Option<i16>
[src]
fn checked_rem(&self, v: &i16) -> Option<i16>
impl CheckedRem for i32
[src]
impl CheckedRem for i32
fn checked_rem(&self, v: &i32) -> Option<i32>
[src]
fn checked_rem(&self, v: &i32) -> Option<i32>
impl CheckedRem for i64
[src]
impl CheckedRem for i64
fn checked_rem(&self, v: &i64) -> Option<i64>
[src]
fn checked_rem(&self, v: &i64) -> Option<i64>
impl CheckedRem for isize
[src]
impl CheckedRem for isize
fn checked_rem(&self, v: &isize) -> Option<isize>
[src]
fn checked_rem(&self, v: &isize) -> Option<isize>
impl CheckedRem for i128
[src]
impl CheckedRem for i128
fn checked_rem(&self, v: &i128) -> Option<i128>
[src]
fn checked_rem(&self, v: &i128) -> Option<i128>