Tracking Issue for unsigned_is_multiple_of
· Issue #128101 · rust-lang/rust (original) (raw)
Feature gate: #![feature(unsigned_is_multiple_of)]
ACP: rust-lang/libs-team#404
This is a tracking issue for the .is_multiple_of
method on unsigned integers.
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 for any non-zero n
, n.is_multiple_of(0) == false
.
If you have a real usecase for this function on signed integer types, let us know! That was not included for simplicity, but if a usecase comes up, adding it will be considered.
Public API
A version of this for all the unsigned types
fn is_multiple_of(lhs: u64, rhs: u64) -> bool { match rhs { // prevent division by zero 0 => lhs == 0, _ => lhs % rhs == 0, } }
Steps / History
- Implementation: add is_multiple_of for unsigned integer types #128103
- Final comment period (FCP)1
- Stabilization PR stabilize unsigned_is_multiple_of #137383
Unresolved Questions
- None yet.