summaryrefslogtreecommitdiffstats
path: root/src/output/render/size.rs
diff options
context:
space:
mode:
authorBenjamin Sago <ogham@bsago.me>2020-10-10 19:49:46 +0100
committerBenjamin Sago <ogham@bsago.me>2020-10-10 20:02:55 +0100
commitf8df02dae7f3cc4121c9bff2c33a584e449ceaa0 (patch)
tree2b3c6368940e8a88affe1c18c8ded6a6292e4f75 /src/output/render/size.rs
parentc3c39fee0af5d8f2265bf03cd680265af04f277f (diff)
Batch source formatting
I read through every file and applied a couple of rustfmt suggestions. The brace placement and alignment of items on similar lines has been made consistent, even if neither are rustfmt's default style (a file has been put in place to enforce this). Other changes are: • Alphabetical imports and modules • Comma placement at the end of match blocks • Use newlines and indentation judiciously • Spaces around associated types • Spaces after negations (it makes it more clear imho) • Comment formatting • Use early-returns and Optional `?` where appropriate
Diffstat (limited to 'src/output/render/size.rs')
-rw-r--r--src/output/render/size.rs14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/output/render/size.rs b/src/output/render/size.rs
index 94e4798..4427a51 100644
--- a/src/output/render/size.rs
+++ b/src/output/render/size.rs
@@ -21,20 +21,23 @@ impl f::Size {
SizeFormat::DecimalBytes => NumberPrefix::decimal(size as f64),
SizeFormat::BinaryBytes => NumberPrefix::binary(size as f64),
SizeFormat::JustBytes => {
+
// Use the binary prefix to select a style.
let prefix = match NumberPrefix::binary(size as f64) {
- NumberPrefix::Standalone(_) => None,
- NumberPrefix::Prefixed(p, _) => Some(p),
+ NumberPrefix::Standalone(_) => None,
+ NumberPrefix::Prefixed(p, _) => Some(p),
};
+
// But format the number directly using the locale.
let string = numerics.format_int(size);
+
return TextCell::paint(colours.size(prefix), string);
- },
+ }
};
let (prefix, n) = match result {
- NumberPrefix::Standalone(b) => return TextCell::paint(colours.size(None), b.to_string()),
- NumberPrefix::Prefixed(p, n) => (p, n)
+ NumberPrefix::Standalone(b) => return TextCell::paint(colours.size(None), b.to_string()),
+ NumberPrefix::Prefixed(p, n) => (p, n),
};
let symbol = prefix.symbol();
@@ -72,6 +75,7 @@ impl f::DeviceIDs {
}
}
+
pub trait Colours {
fn size(&self, prefix: Option<Prefix>) -> Style;
fn unit(&self, prefix: Option<Prefix>) -> Style;