From f8df02dae7f3cc4121c9bff2c33a584e449ceaa0 Mon Sep 17 00:00:00 2001 From: Benjamin Sago Date: Sat, 10 Oct 2020 19:49:46 +0100 Subject: Batch source formatting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/output/render/size.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/output/render/size.rs') 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) -> Style; fn unit(&self, prefix: Option) -> Style; -- cgit v1.2.3