rust-lang / rust-lang/rust

Tracking Issue for `unchecked_div_rem`

Open
#136,716 9 comments 0 reactions 1 assignee View on GitHub

@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
Unresolved Questions

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.