mirror of
https://github.com/ouch-org/ouch.git
synced 2025-06-07 03:55:28 +00:00
cargo fmt
This commit is contained in:
parent
8c51f76d0d
commit
0cd8485028
@ -110,25 +110,16 @@ impl std::fmt::Display for Bytes {
|
|||||||
debug_assert!(num >= 0.0);
|
debug_assert!(num >= 0.0);
|
||||||
if num < 1_f64 {
|
if num < 1_f64 {
|
||||||
let num_pretty = format!("{:.2}", num);
|
let num_pretty = format!("{:.2}", num);
|
||||||
return write!(
|
return write!(f, "{:>6} B", num_pretty);
|
||||||
f,
|
|
||||||
"{:>6} B",
|
|
||||||
num_pretty
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let delimiter = 1000_f64;
|
let delimiter = 1000_f64;
|
||||||
let exponent = cmp::min((num.ln() / 6.90775).floor() as i32, 4);
|
let exponent = cmp::min((num.ln() / 6.90775).floor() as i32, 4);
|
||||||
|
|
||||||
let num_pretty = format!("{:.2}", (num / delimiter.powi(exponent)));
|
let num_pretty = format!("{:.2}", (num / delimiter.powi(exponent)));
|
||||||
let unit_pretty = format!("{}B", Bytes::UNIT_PREFIXES[exponent as usize]);
|
let unit_pretty = format!("{}B", Bytes::UNIT_PREFIXES[exponent as usize]);
|
||||||
|
|
||||||
write!(
|
write!(f, "{:>6} {:>3}", num_pretty, unit_pretty,)
|
||||||
f,
|
|
||||||
"{:>6} {:>3}",
|
|
||||||
num_pretty,
|
|
||||||
unit_pretty,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user