Open
Description
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
Unresolved Questions
- None yet.
Footnotes
Metadata
Assignees
Labels
Category: An issue tracking the progress of sth. like the implementation of an RFCRelevant to the library API team, which will review and decide on the PR/issue.This issue / PR is in PFCP or FCP with a disposition to merge it.Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off.