Skip to content

Commit

Permalink
Make div_ceil const and enhance comment.
Browse files Browse the repository at this point in the history
  • Loading branch information
resistor committed Jul 28, 2022
1 parent 14ac9c9 commit 43c96da
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/uu/sum/src/sum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ static USAGE: &str = "{} [OPTION]... [FILE]...";
static SUMMARY: &str = "Checksum and count the blocks in a file.\n\
With no FILE, or when FILE is -, read standard input.";

// This can be replaced with usize::div_ceil once it is stabilized
fn div_ceil(a: usize, b: usize) -> usize {
// This can be replaced with usize::div_ceil once it is stabilized.
// This implementation approach is optimized for when `b` is a constant,
// particularly a power of two.
const fn div_ceil(a: usize, b: usize) -> usize {
(a + b - 1) / b
}

Expand Down

0 comments on commit 43c96da

Please sign in to comment.