diff options
author | Benjamin Nguyen <benjamin.van.nguyen@gmail.com> | 2023-06-28 11:52:25 +0700 |
---|---|---|
committer | Benjamin Nguyen <benjamin.van.nguyen@gmail.com> | 2023-06-28 11:52:25 +0700 |
commit | 09667829d945ba45416f55e2f8463aedb721e05a (patch) | |
tree | ea0ed10883d095df26fe6d1e2307a41f5d8d49ec | |
parent | 72900d975c68e009dd0d260ba68c7120e7354b2c (diff) |
me like the comma
-rw-r--r-- | rustfmt.toml | 1 | ||||
-rw-r--r-- | src/context/args.rs | 8 | ||||
-rw-r--r-- | src/context/config/toml/mod.rs | 6 | ||||
-rw-r--r-- | src/context/mod.rs | 12 | ||||
-rw-r--r-- | src/disk_usage/file_size/byte.rs | 4 | ||||
-rw-r--r-- | src/icons/fs.rs | 2 | ||||
-rw-r--r-- | src/main.rs | 8 | ||||
-rw-r--r-- | src/progress.rs | 8 | ||||
-rw-r--r-- | src/render/grid/cell.rs | 10 | ||||
-rw-r--r-- | src/render/layout/regular.rs | 2 | ||||
-rw-r--r-- | src/render/long/mod.rs | 16 | ||||
-rw-r--r-- | src/tree/node/cmp.rs | 4 | ||||
-rw-r--r-- | src/tree/node/mod.rs | 12 | ||||
-rw-r--r-- | src/tree/visitor.rs | 2 |
14 files changed, 47 insertions, 48 deletions
diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 0000000..8c795ae --- /dev/null +++ b/rustfmt.toml @@ -0,0 +1 @@ +match_block_trailing_comma = true diff --git a/src/context/args.rs b/src/context/args.rs index 01b06ea..bc4ea68 100644 --- a/src/context/args.rs +++ b/src/context/args.rs @@ -10,10 +10,9 @@ use std::{ /// Allows the implementor to compute [`ArgMatches`] that reconciles arguments from both the /// command-line as well as the config file that gets loaded. pub trait Reconciler: CommandFactory + FromArgMatches { - /// Loads in arguments from both the command-line as well as the config file and reconciles /// identical arguments between the two using these rules: - /// + /// /// 1. If no config file is present, use arguments strictly from the command-line. /// 2. If an argument was provided via the CLI then override the argument from the config. /// 3. If an argument is sourced from its default value because a user didn't provide it via @@ -76,7 +75,7 @@ pub trait Reconciler: CommandFactory + FromArgMatches { { final_args.push(key); }; - } + }, ArgAction::SetFalse => continue, _ => { let Ok(Some(raw)) = argument_source.try_get_raw(id_str) else { @@ -84,7 +83,7 @@ pub trait Reconciler: CommandFactory + FromArgMatches { }; final_args.push(key); final_args.extend(raw.map(OsStr::to_os_string)); - } + }, } } @@ -100,7 +99,6 @@ fn init_empty_args() -> Vec<OsString> { vec![OsString::from("--")] } - /// Loads an [`ArgMatches`] from `.erdtreerc`. #[inline] fn load_rc_config_args() -> Option<ArgMatches> { diff --git a/src/context/config/toml/mod.rs b/src/context/config/toml/mod.rs index 4e7dad6..002580b 100644 --- a/src/context/config/toml/mod.rs +++ b/src/context/config/toml/mod.rs @@ -51,12 +51,12 @@ pub fn parse(config: Config, named_table: Option<&str>) -> Result<Vec<OsString>, let fmt_key = process_key(k); parsed_args.push(fmt_key); parsed_args.push(parsed_value); - } + }, ArgInstructions::PushKeyOnly => { let fmt_key = process_key(k); parsed_args.push(fmt_key); - } + }, ArgInstructions::Pass => continue, } @@ -110,7 +110,7 @@ fn parse_argument(keyword: &str, arg: &Value) -> Result<ArgInstructions, Error> } else { Ok(ArgInstructions::Pass) } - } + }, ValueKind::String(val) => Ok(ArgInstructions::PushKeyValue { parsed_value: OsString::from(val), }), diff --git a/src/context/mod.rs b/src/context/mod.rs index b515f34..03fdd2f 100644 --- a/src/context/mod.rs +++ b/src/context/mod.rs @@ -347,11 +347,11 @@ impl Context { match file_type { file::Type::File if entry_type.map_or(true, |ft| !ft.is_file()) => { return false - } + }, file::Type::Link if entry_type.map_or(true, |ft| !ft.is_symlink()) => { return false - } - _ => {} + }, + _ => {}, } let file_name = dir_entry.file_name().to_string_lossy(); re.is_match(&file_name) @@ -416,11 +416,11 @@ impl Context { match file_type { file::Type::File if entry_type.map_or(true, |ft| !ft.is_file()) => { return false - } + }, file::Type::Link if entry_type.map_or(true, |ft| !ft.is_symlink()) => { return false - } - _ => {} + }, + _ => {}, } let matched = overrides.matched(dir_entry.path(), false); diff --git a/src/disk_usage/file_size/byte.rs b/src/disk_usage/file_size/byte.rs index 37049b3..3301a89 100644 --- a/src/disk_usage/file_size/byte.rs +++ b/src/disk_usage/file_size/byte.rs @@ -123,7 +123,7 @@ impl Display for Metric { } else { format!("{} {}", self.value, SiPrefix::Base) } - } + }, PrefixKind::Bin => { if self.human_readable { let unit = BinPrefix::from(self.value); @@ -138,7 +138,7 @@ impl Display for Metric { } else { format!("{} {}", self.value, BinPrefix::Base) } - } + }, }; write!(f, "{display}")?; diff --git a/src/icons/fs.rs b/src/icons/fs.rs index b19f08f..aa56ac7 100644 --- a/src/icons/fs.rs +++ b/src/icons/fs.rs @@ -61,7 +61,7 @@ pub fn compute_with_color( let ansi_string: ANSIGenericString<str> = fg.bold().paint(icon); let styled_icon = ansi_string.to_string(); Cow::from(styled_icon) - } + }, _ => icon, }; diff --git a/src/main.rs b/src/main.rs index 7b6176b..2bb1f1a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -96,19 +96,19 @@ fn run() -> Result<(), Box<dyn Error>> { layout::Type::Flat => { let render = Engine::<Flat>::new(tree, ctx); format!("{render}") - } + }, layout::Type::Iflat => { let render = Engine::<FlatInverted>::new(tree, ctx); format!("{render}") - } + }, layout::Type::Inverted => { let render = Engine::<Inverted>::new(tree, ctx); format!("{render}") - } + }, layout::Type::Regular => { let render = Engine::<Regular>::new(tree, ctx); format!("{render}") - } + }, }; if let Some(progress) = indicator { diff --git a/src/progress.rs b/src/progress.rs index 4d7bc21..12b3fde 100644 --- a/src/progress.rs +++ b/src/progress.rs @@ -107,8 +107,8 @@ impl<'a> Indicator<'a> { Message::Index => indicator.index()?, Message::DoneIndexing => { indicator.update_state(IndicatorState::Rendering)?; - } - Message::RenderReady => {} + }, + Message::RenderReady => {}, } } @@ -137,14 +137,14 @@ impl<'a> Indicator<'a> { stdout.execute(terminal::Clear(ClearType::CurrentLine))?; stdout.execute(cursor::RestorePosition)?; self.rendering(); - } + }, (Rendering, Done) => { let stdout = &mut self.stdout; stdout.execute(terminal::Clear(ClearType::CurrentLine))?; stdout.execute(cursor::RestorePosition)?; stdout.execute(cursor::Show)?; - } + }, _ => (), } diff --git a/src/render/grid/cell.rs b/src/render/grid/cell.rs index b0e5849..c24172e 100644 --- a/src/render/grid/cell.rs +++ b/src/render/grid/cell.rs @@ -79,7 +79,7 @@ impl<'a> Cell<'a> { let icon = node.compute_icon(ctx.no_color()); write!(f, "{pre}{icon} {name}") - } + }, _ => unreachable!(), } @@ -319,11 +319,11 @@ impl<'a> Cell<'a> { PrefixKind::Si => { let pre = SiPrefix::from(metric.value); styles::get_du_theme().unwrap().get(pre.as_str()).unwrap() - } + }, PrefixKind::Bin => { let pre = BinPrefix::from(metric.value); styles::get_du_theme().unwrap().get(pre.as_str()).unwrap() - } + }, } }; @@ -351,11 +351,11 @@ impl<'a> Cell<'a> { PrefixKind::Si => { let pre = SiPrefix::from(bytes); styles::get_du_theme().unwrap().get(pre.as_str()).unwrap() - } + }, PrefixKind::Bin => { let pre = BinPrefix::from(bytes); styles::get_du_theme().unwrap().get(pre.as_str()).unwrap() - } + }, }; let out = color.paint(format!("{metric:>max_size_width$}")); diff --git a/src/render/layout/regular.rs b/src/render/layout/regular.rs index 7ba14b4..09ed9f4 100644 --- a/src/render/layout/regular.rs +++ b/src/render/layout/regular.rs @@ -50,7 +50,7 @@ impl Display for Engine<Regular> { } continue; - } + }, }; file_count_data.push(Tree::compute_file_count(current_node_id, arena)); diff --git a/src/render/long/mod.rs b/src/render/long/mod.rs index cd38cff..2a01c94 100644 --- a/src/render/long/mod.rs +++ b/src/render/long/mod.rs @@ -67,7 +67,7 @@ impl fmt::Display for Display<'_> { match (group, ino, nlink) { (false, false, false) => { write!(f, "{perms} {owner} {time}") - } + }, (true, true, true) => { let group_out = Cell::new(node, ctx, cell::Kind::Group); @@ -78,46 +78,46 @@ impl fmt::Display for Display<'_> { f, "{ino_out} {perms} {nlink_out} {owner} {group_out} {time}" ) - } + }, (true, false, false) => { let group_out = Cell::new(node, ctx, cell::Kind::Group); write!(f, "{perms} {owner} {group_out} {time}") - } + }, (true, true, false) => { let group_out = Cell::new(node, ctx, cell::Kind::Group); let ino_out = Cell::new(node, ctx, cell::Kind::Ino); write!(f, "{ino_out} {perms} {owner} {group_out} {time}") - } + }, (false, false, true) => { let nlink_out = Cell::new(node, ctx, cell::Kind::Nlink); write!(f, "{perms} {nlink_out} {owner} {time}") - } + }, (true, false, true) => { let group_out = Cell::new(node, ctx, cell::Kind::Group); let nlink_out = Cell::new(node, ctx, cell::Kind::Nlink); write!(f, "{perms} {nlink_out} {owner} {group_out} {time}") - } + }, (false, true, false) => { let ino_out = Cell::new(node, ctx, cell::Kind::Ino); write!(f, "{ino_out} {perms} {owner} {time}") - } + }, (false, true, true) => { let ino_out = Cell::new(node, ctx, cell::Kind::Ino); let nlink_out = Cell::new(node, ctx, cell::Kind::Nlink); write!(f, "{ino_out} {perms} {nlink_out} {owner} {time}") - } + }, } } } diff --git a/src/tree/node/cmp.rs b/src/tree/node/cmp.rs index d5301c9..cac2bda 100644 --- a/src/tree/node/cmp.rs +++ b/src/tree/node/cmp.rs @@ -12,10 +12,10 @@ pub fn comparator(ctx: &Context) -> Box<NodeComparator> { match ctx.dir_order { dir::Order::First => { Box::new(move |a, b| dir_first_comparator(a, b, base_comparator(sort_type))) - } + }, dir::Order::Last => { Box::new(move |a, b| dir_last_comparator(a, b, base_comparator(sort_type))) - } + }, dir::Order::None => base_comparator(sort_type), } } diff --git a/src/tree/node/mod.rs b/src/tree/node/mod.rs index 4d09b03..cca2e9e 100644 --- a/src/tree/node/mod.rs +++ b/src/tree/node/mod.rs @@ -256,28 +256,28 @@ impl TryFrom<(DirEntry, &Context)> for Node { DiskUsage::Logical => { let metric = byte::Metric::init_logical(&metadata, ctx.unit, ctx.human); Some(FileSize::Byte(metric)) - } + }, DiskUsage::Physical => { let metric = byte::Metric::init_physical(path, &metadata, ctx.unit, ctx.human); Some(FileSize::Byte(metric)) - } + }, DiskUsage::Line => { let metric = line_count::Metric::init(path); metric.map(FileSize::Line) - } + }, DiskUsage::Word => { let metric = word_count::Metric::init(path); metric.map(FileSize::Word) - } + }, #[cfg(unix)] DiskUsage::Block => { let metric = block::Metric::init(&metadata); Some(FileSize::Block(metric)) - } + }, } - } + }, _ => None, }; diff --git a/src/tree/visitor.rs b/src/tree/visitor.rs index 1900b4f..f0ff955 100644 --- a/src/tree/visitor.rs +++ b/src/tree/visitor.rs @@ -46,7 +46,7 @@ impl ParallelVisitor for Branch<'_> { Ok(node) => { self.tx.send(TraversalState::from(node)).unwrap(); WalkState::Continue - } + }, _ => WalkState::Skip, } } |