pub trait MultipleOf: Sized + Rem<Self> {
// Required method
fn is_multiple_of(self, rhs: Self) -> bool;
}Expand description
Checks divisibility, mirroring is_multiple_of on the unsigned primitives.
Required Methods§
Sourcefn is_multiple_of(self, rhs: Self) -> bool
fn is_multiple_of(self, rhs: Self) -> bool
Returns true if self is an integer multiple of rhs, and false
otherwise.
This function is equivalent to self % rhs == 0, except that it
will not panic for rhs == 0: instead, 0.is_multiple_of(0) == true
and x.is_multiple_of(0) == false for any nonzero x.
Like std, this is only provided for unsigned types.
use const_num_traits::MultipleOf;
assert!(MultipleOf::is_multiple_of(6u8, 2));
assert!(!MultipleOf::is_multiple_of(5u8, 2));
assert!(MultipleOf::is_multiple_of(0u8, 0));
assert!(!MultipleOf::is_multiple_of(5u8, 0));Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".