Tracking Issue for `unchecked_div_rem`
Open
@madhav-madhusoodanan is already working on this.
Since Feb 23, 2025.
C-tracking-issue
E-easy
E-help-wanted
T-libs
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Feature gate: #![feature(unchecked_div_rem)]
This is a tracking issue for unchecked versions of / and % on integers. This is similar to existing methods like unchecked_mul.
Public API
// in core
impl {i8, u8, i16, u16, i32, u32, i64, u64, i128, u128} {
// Same preconditions as the versions in intrinsics
/// Performs an unchecked division, resulting in undefined behavior where y == 0 or x == T::MIN && y == -1.
pub fn unchecked_div(self, rhs: Self) -> Self;
/// Returns the remainder of an unchecked division, resulting in undefined behavior when y == 0 or x == T::MIN && y == -1.
pub fn unchecked_rem(self, rhs: Self) -> Self;
}
Steps / History
- ACP: https://github.com/rust-lang/libs-team/issues/526
- Implementation: #...
- Final comment period (FCP)^1
- Stabilization PR
Unresolved Questions
- Signed and unsigned have different preconditions; should the names be different as a stumbling stone when changing between the two? https://github.com/rust-lang/rust/issues/136716#issuecomment-2645029772
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.