Skip to content

Commit 96be503

Browse files
committed
df: source SI/IEC bases from uucore::parser::parse_size
1 parent 0a2cdad commit 96be503

1 file changed

Lines changed: 5 additions & 31 deletions

File tree

src/uu/df/src/blocks.rs

Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -9,37 +9,11 @@ use std::{env, fmt};
99

1010
use uucore::{
1111
display::Quotable,
12-
parser::parse_size::{ParseSizeError, parse_size_non_zero_u64, parse_size_u64},
12+
parser::parse_size::{
13+
IEC_BASES, ParseSizeError, SI_BASES, parse_size_non_zero_u64, parse_size_u64,
14+
},
1315
};
1416

15-
/// The first ten powers of 1024.
16-
const IEC_BASES: [u128; 10] = [
17-
1,
18-
1_024,
19-
1_048_576,
20-
1_073_741_824,
21-
1_099_511_627_776,
22-
1_125_899_906_842_624,
23-
1_152_921_504_606_846_976,
24-
1_180_591_620_717_411_303_424,
25-
1_208_925_819_614_629_174_706_176,
26-
1_237_940_039_285_380_274_899_124_224,
27-
];
28-
29-
/// The first ten powers of 1000.
30-
const SI_BASES: [u128; 10] = [
31-
1,
32-
1_000,
33-
1_000_000,
34-
1_000_000_000,
35-
1_000_000_000_000,
36-
1_000_000_000_000_000,
37-
1_000_000_000_000_000_000,
38-
1_000_000_000_000_000_000_000,
39-
1_000_000_000_000_000_000_000_000,
40-
1_000_000_000_000_000_000_000_000_000,
41-
];
42-
4317
/// A `SuffixType` determines whether the suffixes are 1000 or 1024 based, and whether they are
4418
/// intended for `HumanReadable` mode or not.
4519
#[derive(Clone, Copy)]
@@ -50,8 +24,8 @@ pub(crate) enum SuffixType {
5024
}
5125

5226
impl SuffixType {
53-
/// The first ten powers of 1024 and 1000, respectively.
54-
fn bases(self) -> [u128; 10] {
27+
/// The first eleven powers of 1024 and 1000, respectively.
28+
fn bases(self) -> [u128; 11] {
5529
match self {
5630
Self::Iec | Self::HumanReadable(HumanReadable::Binary) => IEC_BASES,
5731
Self::Si | Self::HumanReadable(HumanReadable::Decimal) => SI_BASES,

0 commit comments

Comments
 (0)