pub trait DivExact:
Sized
+ Div<Self>
+ Rem<Self> {
// Required methods
fn div_exact(self, rhs: Self) -> Option<<Self as Div<Self>>::Output>;
fn checked_div_exact(self, rhs: Self) -> Option<<Self as Div<Self>>::Output>;
}Expand description
Performs division without remainder.
Required Methods§
Sourcefn div_exact(self, rhs: Self) -> Option<<Self as Div<Self>>::Output>
fn div_exact(self, rhs: Self) -> Option<<Self as Div<Self>>::Output>
Integer division without remainder. Computes self / rhs, returning
None if self % rhs != 0.
§Panics
Panics if rhs is zero, or — with overflow checks enabled — on
MIN / -1 for signed types.
use const_num_traits::DivExact;
assert_eq!(DivExact::div_exact(64u8, 2), Some(32));
assert_eq!(DivExact::div_exact(65u8, 2), None);Sourcefn checked_div_exact(self, rhs: Self) -> Option<<Self as Div<Self>>::Output>
fn checked_div_exact(self, rhs: Self) -> Option<<Self as Div<Self>>::Output>
Checked integer division without remainder. Computes self / rhs,
returning None if rhs == 0, self % rhs != 0, or the division
overflowed (MIN / -1 on a signed type).
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".