diff options
author | Brooks Rady <b.j.rady@gmail.com> | 2020-05-08 15:18:53 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-08 16:18:53 +0200 |
commit | ae3ca6e5f1bb4f9b03f30f8291cc10b9aec07bb8 (patch) | |
tree | c7ba2a44a2a13ef8ef5f455d797ed64cad2b7326 | |
parent | 747076a2d7f27d73242df13ff79c99d8f429a7a7 (diff) |
fix(formatting): add terabytes as a display unit (#168)
-rw-r--r-- | src/display/components/display_bandwidth.rs | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/display/components/display_bandwidth.rs b/src/display/components/display_bandwidth.rs index dcc204c..04f1e89 100644 --- a/src/display/components/display_bandwidth.rs +++ b/src/display/components/display_bandwidth.rs @@ -8,7 +8,9 @@ pub struct DisplayBandwidth { impl fmt::Display for DisplayBandwidth { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let suffix = if self.as_rate { "ps" } else { "" }; - if self.bandwidth > 999_999_999.0 { + if self.bandwidth > 999_999_999_999.0 { + write!(f, "{:.2}TB{}", self.bandwidth / 1_000_000_000_000.0, suffix) + } else if self.bandwidth > 999_999_999.0 { write!(f, "{:.2}GB{}", self.bandwidth / 1_000_000_000.0, suffix) } else if self.bandwidth > 999_999.0 { write!(f, "{:.2}MB{}", self.bandwidth / 1_000_000.0, suffix) |