{
"$type": "site.standard.document",
"bskyPostRef": {
"cid": "bafyreigl2qgsm37oqcmptcqsyntwfyl772rjpcjmg4ftfmojpk5wo33jxa",
"uri": "at://did:plc:ivbknywyskln22er3nkssdhl/app.bsky.feed.post/3mnuq4gstwj62"
},
"path": "/t/why-is-strict-div-implemented-in-terms-of-overflowing-div-for-signed-integers/24387#post_1",
"publishedAt": "2026-06-09T16:58:48.000Z",
"site": "https://internals.rust-lang.org",
"textContent": "I was unable to find a satisfying answer to this question, so I thought I'd ask here. `strict_div` is currently implemented as follows for signed integers:\n\n\n pub const fn strict_div(self, rhs: Self) -> Self {\n let (a, b) = self.overflowing_div(rhs);\n if b { imp::overflow_panic::div() } else { a }\n }\n\n\nHowever, `div` already panics on overflow even in release mode, meaning that `strict_div` should be exactly equivalent to `div`. This made me wonder why signed integers don't use the same implementation strategy as unsigned integers:\n\n\n pub const fn strict_div(self, rhs: Self) -> Self {\n self / rhs\n }\n\n\nCan anyone offer any insights?",
"title": "Why is strict_div implemented in terms of overflowing_div for signed integers?"
}