Skip to content

Commit 2d2e9ff

Browse files
committed
Bump bytesize major version from 1 to 2
And adapt `Bytes::format_bytes()` to the API change. The old `bytesize::to_string()` function is confusing in its second parameter `si_prefix: bool`, which is why it was removed. But it looks like a value of `false`, as we were passing, actually caused decimal SI units (rather than binary IEC units) to be used. It's not obvious which units `prodash` intended to use `bytesize` to convert to and display in. But this seems to be a minimal change to adapt to the new major version. In spite of the name `si_prefix` for the old parameter, experiments show that setting it to `true` caused values to be converted to and presented in binary IEC units. Although this attempts not to change the units that are used, is is expected to produce observable differneces for some of them, in how they are presented. In particular, a decimal SI kilobyte is least ambiguously abbreviated "kB" (because "k" is an SI unit symbol prefix for "kilo" in its meaning of 1000), but it was previously written as "KB". It is now expected to be writen as "kB". See also: GitoxideLabs/gitoxide#1947 (comment)
1 parent 58ea133 commit 2d2e9ff

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ signal-hook = { version = "0.3.9", optional = true, default-features = false }
8484
is-terminal = { version = "0.4.9", optional = true }
8585

8686
# units
87-
bytesize = { version = "1.0.1", optional = true }
87+
bytesize = { version = "2.0.1", optional = true }
8888
human_format = { version = "1.0.3", optional = true }
8989

9090
[package.metadata.docs.rs]

src/unit/bytes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ pub struct Bytes;
88

99
impl Bytes {
1010
fn format_bytes(w: &mut dyn fmt::Write, value: Step) -> fmt::Result {
11-
let string = bytesize::to_string(value as u64, false);
11+
let string = bytesize::ByteSize(value as u64).display().si().to_string();
1212
for token in string.split(' ') {
1313
w.write_str(token)?;
1414
}

0 commit comments

Comments
 (0)