Skip to content

Commit 9c913af

Browse files
committed
Use Ki instead of ki
1 parent c0b7e8b commit 9c913af

6 files changed

+13
-13
lines changed

crates/crates_io_og_image/src/formatting.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use serde::Serializer;
2222
/// A formatted string representing the size with appropriate units
2323
pub fn format_bytes(bytes: u32) -> String {
2424
const THRESHOLD: f64 = 1500.;
25-
const UNITS: &[&str] = &["B", "kiB", "MiB"];
25+
const UNITS: &[&str] = &["B", "KiB", "MiB"];
2626

2727
let mut value = bytes as f64;
2828
let mut unit_index = 0;
@@ -40,15 +40,15 @@ pub fn format_bytes(bytes: u32) -> String {
4040
return format!("{bytes} {unit}");
4141
}
4242

43-
// For kiB and MiB, format with appropriate decimal places
43+
// For KiB and MiB, format with appropriate decimal places
4444

4545
// Determine number of decimal places to keep number under 4 chars
4646
if value < 10.0 {
47-
format!("{value:.2} {unit}") // e.g., 1.50 kiB, 9.99 MiB
47+
format!("{value:.2} {unit}") // e.g., 1.50 KiB, 9.99 MiB
4848
} else if value < 100.0 {
49-
format!("{value:.1} {unit}") // e.g., 10.5 kiB, 99.9 MiB
49+
format!("{value:.1} {unit}") // e.g., 10.5 KiB, 99.9 MiB
5050
} else {
51-
format!("{value:.0} {unit}") // e.g., 100 kiB, 999 MiB
51+
format!("{value:.0} {unit}") // e.g., 100 KiB, 999 MiB
5252
}
5353
}
5454

@@ -128,14 +128,14 @@ mod tests {
128128
assert_eq!(format_bytes(1499), "1499 B");
129129

130130
// Test kilobytes format (1500 bytes to 1500 * 1024 bytes)
131-
assert_eq!(format_bytes(1500), "1.46 kiB");
132-
assert_eq!(format_bytes(2048), "2.00 kiB");
133-
assert_eq!(format_bytes(5120), "5.00 kiB");
134-
assert_eq!(format_bytes(10240), "10.0 kiB");
135-
assert_eq!(format_bytes(51200), "50.0 kiB");
136-
assert_eq!(format_bytes(102400), "100 kiB");
137-
assert_eq!(format_bytes(512000), "500 kiB");
138-
assert_eq!(format_bytes(1048575), "1024 kiB");
131+
assert_eq!(format_bytes(1500), "1.46 KiB");
132+
assert_eq!(format_bytes(2048), "2.00 KiB");
133+
assert_eq!(format_bytes(5120), "5.00 KiB");
134+
assert_eq!(format_bytes(10240), "10.0 KiB");
135+
assert_eq!(format_bytes(51200), "50.0 KiB");
136+
assert_eq!(format_bytes(102400), "100 KiB");
137+
assert_eq!(format_bytes(512000), "500 KiB");
138+
assert_eq!(format_bytes(1048575), "1024 KiB");
139139

140140
// Test megabytes format (above 1500 * 1024 bytes)
141141
assert_eq!(format_bytes(1536000), "1.46 MiB");
34 Bytes
Loading
86 Bytes
Loading
73 Bytes
Loading
63 Bytes
Loading
84 Bytes
Loading

0 commit comments

Comments
 (0)