1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

du: use div_ceil() from std

This commit is contained in:
Daniel Hofstetter 2024-11-20 09:10:39 +01:00
parent c94b2e9105
commit 28e9a88077

View file

@ -555,7 +555,7 @@ impl StatPrinter {
size, size,
uucore::format::human::SizeFormat::Binary, uucore::format::human::SizeFormat::Binary,
), ),
SizeFormat::BlockSize(block_size) => div_ceil(size, block_size).to_string(), SizeFormat::BlockSize(block_size) => size.div_ceil(block_size).to_string(),
} }
} }
@ -576,13 +576,6 @@ impl StatPrinter {
} }
} }
// This can be replaced with u64::div_ceil once it is stabilized.
// This implementation approach is optimized for when `b` is a constant,
// particularly a power of two.
pub fn div_ceil(a: u64, b: u64) -> u64 {
(a + b - 1) / b
}
// Read file paths from the specified file, separated by null characters // Read file paths from the specified file, separated by null characters
fn read_files_from(file_name: &str) -> Result<Vec<PathBuf>, std::io::Error> { fn read_files_from(file_name: &str) -> Result<Vec<PathBuf>, std::io::Error> {
let reader: Box<dyn BufRead> = if file_name == "-" { let reader: Box<dyn BufRead> = if file_name == "-" {