pub trait WrappingDiv: Sized + Div<Self> {
// Required method
fn wrapping_div(self, v: Self) -> <Self as Div<Self>>::Output;
}Expand description
Performs division that wraps around on overflow.
Required Methods§
Sourcefn wrapping_div(self, v: Self) -> <Self as Div<Self>>::Output
fn wrapping_div(self, v: Self) -> <Self as Div<Self>>::Output
Wrapping (modular) division. Computes self / other, wrapping around
at the boundary of the type.
The only case where such wrapping can occur is when one divides
MIN / -1 on a signed type; this is equivalent to -MIN, a positive
value that is too large to represent in the type. For unsigned types
this is a normal division and can never wrap.
§Panics
Panics if other is zero.
use const_num_traits::WrappingDiv;
assert_eq!(WrappingDiv::wrapping_div(100i8, 10), 10);
assert_eq!(WrappingDiv::wrapping_div(i8::MIN, -1), i8::MIN); // wrapped!Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".