Skip to content

Commit

Permalink
Rollup merge of rust-lang#127122 - TDecking:div_ceil, r=Nilstrieb
Browse files Browse the repository at this point in the history
Remove uneccessary condition in `div_ceil`

Previously, `div_ceil` for unsigned integers had a `rhs > 0` for rounding. That condition however is always fulfilled, since `rhs == 0` would mean a division by zero earlier.
  • Loading branch information
matthiaskrgr authored Jun 29, 2024
2 parents 171f5db + 50a6646 commit 05a472c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion core/src/num/uint_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2726,7 +2726,7 @@ macro_rules! uint_impl {
pub const fn div_ceil(self, rhs: Self) -> Self {
let d = self / rhs;
let r = self % rhs;
if r > 0 && rhs > 0 {
if r > 0 {
d + 1
} else {
d
Expand Down

0 comments on commit 05a472c

Please sign in to comment.