summaryrefslogtreecommitdiffstats
path: root/src/utils/gen_util.rs
diff options
context:
space:
mode:
authorClementTsang <clementjhtsang@gmail.com>2019-12-28 01:20:05 -0500
committerClementTsang <clementjhtsang@gmail.com>2019-12-28 01:20:05 -0500
commitad4f124d9d0f87b3f21169d8c8d08267596cfaae (patch)
treeeca62d89c69824b120195ac50400b3f5a91c2f19 /src/utils/gen_util.rs
parentf7243bd78b571065bf1292d0d06e7736903c519a (diff)
Rearrange to fit legend and extra info.
Diffstat (limited to 'src/utils/gen_util.rs')
-rw-r--r--src/utils/gen_util.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/utils/gen_util.rs b/src/utils/gen_util.rs
index 30a257bc..0c26286e 100644
--- a/src/utils/gen_util.rs
+++ b/src/utils/gen_util.rs
@@ -24,9 +24,9 @@ pub fn float_max(a: f32, b: f32) -> f32 {
/// Returns a tuple containing the value and the unit. In units of 1024.
/// This only supports up to a tebibyte.
-pub fn get_exact_byte_values(bytes: u64) -> (f64, String) {
+pub fn get_exact_byte_values(bytes: u64, spacing: bool) -> (f64, String) {
match bytes {
- b if b < 1024 => (bytes as f64, "B".to_string()),
+ b if b < 1024 => (bytes as f64, if spacing { " B".to_string() } else { "B".to_string() }),
b if b < 1_048_576 => (bytes as f64 / 1024.0, "KiB".to_string()),
b if b < 1_073_741_824 => (bytes as f64 / 1_048_576.0, "MiB".to_string()),
b if b < 1_099_511_627_776 => (bytes as f64 / 1_073_741_824.0, "GiB".to_string()),
@@ -36,9 +36,9 @@ pub fn get_exact_byte_values(bytes: u64) -> (f64, String) {
/// Returns a tuple containing the value and the unit. In units of 1000.
/// This only supports up to a terabyte. Note the "byte" unit will have a space appended to match the others.
-pub fn get_simple_byte_values(bytes: u64) -> (f64, String) {
+pub fn get_simple_byte_values(bytes: u64, spacing: bool) -> (f64, String) {
match bytes {
- b if b < 1000 => (bytes as f64, "B".to_string()),
+ b if b < 1000 => (bytes as f64, if spacing { " B".to_string() } else { "B".to_string() }),
b if b < 1_000_000 => (bytes as f64 / 1000.0, "KB".to_string()),
b if b < 1_000_000_000 => (bytes as f64 / 1_000_000.0, "MB".to_string()),
b if b < 1_000_000_000_000 => (bytes as f64 / 1_000_000_000.0, "GB".to_string()),