From 660cae214316441b32e43b7dcfe9c35d326be3be Mon Sep 17 00:00:00 2001 From: Narawit Rakket Date: Tue, 14 Jun 2022 01:19:49 +0700 Subject: [PATCH] refactor: remove unnecessary use of vec! macro --- src/display.rs | 16 +++++++------- src/flags/blocks.rs | 36 ++++++++++++++++---------------- src/flags/color.rs | 12 +++++------ src/flags/date.rs | 20 +++++++++--------- src/flags/dereference.rs | 4 ++-- src/flags/display.rs | 8 +++---- src/flags/header.rs | 4 ++-- src/flags/hyperlink.rs | 12 +++++------ src/flags/icons.rs | 20 +++++++++--------- src/flags/ignore_globs.rs | 8 +++---- src/flags/indicators.rs | 4 ++-- src/flags/layout.rs | 10 ++++----- src/flags/permission.rs | 4 ++-- src/flags/recursion.rs | 24 ++++++++++----------- src/flags/size.rs | 4 ++-- src/flags/sorting.rs | 44 +++++++++++++++++++-------------------- src/flags/symlinks.rs | 4 ++-- src/flags/total_size.rs | 4 ++-- src/meta/symlink.rs | 6 +++--- 19 files changed, 122 insertions(+), 122 deletions(-) diff --git a/src/display.rs b/src/display.rs index 685e3f8..87b9bab 100644 --- a/src/display.rs +++ b/src/display.rs @@ -316,7 +316,7 @@ fn get_output<'a>( Block::INode => block_vec.push(meta.inode.render(colors)), Block::Links => block_vec.push(meta.links.render(colors)), Block::Permission => { - block_vec.extend(vec![ + block_vec.extend([ meta.file_type.render(colors), meta.permissions.render(colors, flags), meta.access_control.render_method(colors), @@ -336,7 +336,7 @@ fn get_output<'a>( Block::SizeValue => block_vec.push(meta.size.render_value(colors, flags)), Block::Date => block_vec.push(meta.date.render(colors, flags)), Block::Name => { - block_vec.extend(vec![ + block_vec.extend([ meta.name .render(colors, icons, display_option, flags.hyperlink), meta.indicator.render(flags), @@ -607,7 +607,7 @@ mod tests { #[test] fn test_display_tree_with_all() { - let argv = vec!["lsd", "--tree", "--all"]; + let argv = ["lsd", "--tree", "--all"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); let flags = Flags::configure_from(&matches, &Config::with_none()).unwrap(); @@ -639,7 +639,7 @@ mod tests { /// `---blocks size,name` can help us for this case #[test] fn test_tree_align_subfolder() { - let argv = vec!["lsd", "--tree", "--blocks", "size,name"]; + let argv = ["lsd", "--tree", "--blocks", "size,name"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); let flags = Flags::configure_from(&matches, &Config::with_none()).unwrap(); @@ -678,7 +678,7 @@ mod tests { #[test] #[cfg(unix)] fn test_tree_size_first_without_name() { - let argv = vec!["lsd", "--tree", "--blocks", "size,permission"]; + let argv = ["lsd", "--tree", "--blocks", "size,permission"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); let flags = Flags::configure_from(&matches, &Config::with_none()).unwrap(); @@ -716,7 +716,7 @@ mod tests { #[test] fn test_tree_edge_before_name() { - let argv = vec!["lsd", "--tree", "--long"]; + let argv = ["lsd", "--tree", "--long"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); let flags = Flags::configure_from(&matches, &Config::with_none()).unwrap(); @@ -740,7 +740,7 @@ mod tests { #[test] fn test_grid_all_block_headers() { - let argv = vec![ + let argv = [ "lsd", "--header", "--blocks", @@ -778,7 +778,7 @@ mod tests { #[test] fn test_grid_no_header_with_empty_meta() { - let argv = vec!["lsd", "--header", "-l"]; + let argv = ["lsd", "--header", "-l"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); let flags = Flags::configure_from(&matches, &Config::with_none()).unwrap(); diff --git a/src/flags/blocks.rs b/src/flags/blocks.rs index da039e3..a871aab 100644 --- a/src/flags/blocks.rs +++ b/src/flags/blocks.rs @@ -261,7 +261,7 @@ mod test_blocks { #[test] fn test_configure_from_without_long() { - let argv = vec!["lsd"]; + let argv = ["lsd"]; let target = Ok::<_, Error>(Blocks::default()); let matches = app::build().get_matches_from_safe(argv).unwrap(); @@ -272,7 +272,7 @@ mod test_blocks { #[test] fn test_configure_from_with_long() { - let argv = vec!["lsd", "--long"]; + let argv = ["lsd", "--long"]; let target = Ok::<_, Error>(Blocks::long()); let matches = app::build().get_matches_from_safe(argv).unwrap(); @@ -283,7 +283,7 @@ mod test_blocks { #[test] fn test_configure_from_with_blocks_and_without_long() { - let argv = vec!["lsd", "--blocks", "permission"]; + let argv = ["lsd", "--blocks", "permission"]; let target = Ok::<_, Error>(Blocks(vec![Block::Permission])); let matches = app::build().get_matches_from_safe(argv).unwrap(); @@ -294,7 +294,7 @@ mod test_blocks { #[test] fn test_configure_from_with_blocks_and_long() { - let argv = vec!["lsd", "--long", "--blocks", "permission"]; + let argv = ["lsd", "--long", "--blocks", "permission"]; let target = Ok::<_, Error>(Blocks(vec![Block::Permission])); let matches = app::build().get_matches_from_safe(argv).unwrap(); @@ -305,7 +305,7 @@ mod test_blocks { #[test] fn test_configure_from_with_inode() { - let argv = vec!["lsd", "--inode"]; + let argv = ["lsd", "--inode"]; let mut target_blocks = Blocks::default(); target_blocks.0.insert(0, Block::INode); @@ -319,7 +319,7 @@ mod test_blocks { #[test] fn test_configure_from_prepend_inode_without_long() { - let argv = vec!["lsd", "--blocks", "permission", "--inode"]; + let argv = ["lsd", "--blocks", "permission", "--inode"]; let mut target_blocks = Blocks(vec![Block::Permission]); target_blocks.0.insert(0, Block::INode); @@ -333,7 +333,7 @@ mod test_blocks { #[test] fn test_configure_from_prepend_inode_with_long() { - let argv = vec!["lsd", "--long", "--blocks", "permission", "--inode"]; + let argv = ["lsd", "--long", "--blocks", "permission", "--inode"]; let target = Ok::<_, Error>(Blocks(vec![Block::INode, Block::Permission])); let matches = app::build().get_matches_from_safe(argv).unwrap(); @@ -344,7 +344,7 @@ mod test_blocks { #[test] fn test_configure_from_ignore_prepend_inode_without_long() { - let argv = vec!["lsd", "--blocks", "permission,inode", "--inode"]; + let argv = ["lsd", "--blocks", "permission,inode", "--inode"]; let target = Ok::<_, Error>(Blocks(vec![Block::Permission, Block::INode])); @@ -356,7 +356,7 @@ mod test_blocks { #[test] fn test_configure_from_ignore_prepend_inode_with_long() { - let argv = vec!["lsd", "--long", "--blocks", "permission,inode", "--inode"]; + let argv = ["lsd", "--long", "--blocks", "permission,inode", "--inode"]; let target = Ok::<_, Error>(Blocks(vec![Block::Permission, Block::INode])); let matches = app::build().get_matches_from_safe(argv).unwrap(); @@ -367,7 +367,7 @@ mod test_blocks { #[test] fn test_from_arg_matches_none() { - let argv = vec!["lsd"]; + let argv = ["lsd"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert!(match Blocks::from_arg_matches(&matches) { None => true, @@ -377,7 +377,7 @@ mod test_blocks { #[test] fn test_from_arg_matches_one() { - let argv = vec!["lsd", "--blocks", "permission"]; + let argv = ["lsd", "--blocks", "permission"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); let test_blocks = Blocks(vec![Block::Permission]); assert!(match Blocks::from_arg_matches(&matches) { @@ -388,7 +388,7 @@ mod test_blocks { #[test] fn test_from_arg_matches_multi_occurences() { - let argv = vec!["lsd", "--blocks", "permission", "--blocks", "name"]; + let argv = ["lsd", "--blocks", "permission", "--blocks", "name"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); let test_blocks = Blocks(vec![Block::Permission, Block::Name]); assert!(match Blocks::from_arg_matches(&matches) { @@ -399,7 +399,7 @@ mod test_blocks { #[test] fn test_from_arg_matches_multi_values() { - let argv = vec!["lsd", "--blocks", "permission,name"]; + let argv = ["lsd", "--blocks", "permission,name"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); let test_blocks = Blocks(vec![Block::Permission, Block::Name]); assert!(match Blocks::from_arg_matches(&matches) { @@ -410,7 +410,7 @@ mod test_blocks { #[test] fn test_from_arg_matches_reversed_default() { - let argv = vec!["lsd", "--blocks", "name,date,size,group,user,permission"]; + let argv = ["lsd", "--blocks", "name,date,size,group,user,permission"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); let test_blocks = Blocks(vec![ Block::Name, @@ -428,7 +428,7 @@ mod test_blocks { #[test] fn test_from_arg_matches_every_second_one() { - let argv = vec!["lsd", "--blocks", "permission,group,date"]; + let argv = ["lsd", "--blocks", "permission,group,date"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); let test_blocks = Blocks(vec![Block::Permission, Block::Group, Block::Date]); assert!(match Blocks::from_arg_matches(&matches) { @@ -495,7 +495,7 @@ mod test_blocks { #[test] fn test_context_not_present_on_cli() { - let argv = vec!["lsd", "--long"]; + let argv = ["lsd", "--long"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); let parsed_blocks = Blocks::configure_from(&matches, &Config::with_none()).unwrap(); let it = parsed_blocks.0.iter(); @@ -504,7 +504,7 @@ mod test_blocks { #[test] fn test_context_present_if_context_on() { - let argv = vec!["lsd", "--context"]; + let argv = ["lsd", "--context"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); let parsed_blocks = Blocks::configure_from(&matches, &Config::with_none()).unwrap(); let it = parsed_blocks.0.iter(); @@ -513,7 +513,7 @@ mod test_blocks { #[test] fn test_only_one_context_no_other_blocks_affected() { - let argv = vec![ + let argv = [ "lsd", "--context", "--blocks", diff --git a/src/flags/color.rs b/src/flags/color.rs index 4d07baa..e39a184 100644 --- a/src/flags/color.rs +++ b/src/flags/color.rs @@ -187,14 +187,14 @@ mod test_color_option { #[test] fn test_from_arg_matches_none() { - let argv = vec!["lsd"]; + let argv = ["lsd"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!(None, ColorOption::from_arg_matches(&matches)); } #[test] fn test_from_arg_matches_always() { - let argv = vec!["lsd", "--color", "always"]; + let argv = ["lsd", "--color", "always"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!( Some(ColorOption::Always), @@ -204,7 +204,7 @@ mod test_color_option { #[test] fn test_from_arg_matches_auto() { - let argv = vec!["lsd", "--color", "auto"]; + let argv = ["lsd", "--color", "auto"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!( Some(ColorOption::Auto), @@ -214,7 +214,7 @@ mod test_color_option { #[test] fn test_from_arg_matches_never() { - let argv = vec!["lsd", "--color", "never"]; + let argv = ["lsd", "--color", "never"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!( Some(ColorOption::Never), @@ -230,7 +230,7 @@ mod test_color_option { #[test] fn test_from_arg_matches_classic_mode() { - let argv = vec!["lsd", "--color", "always", "--classic"]; + let argv = ["lsd", "--color", "always", "--classic"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!( Some(ColorOption::Never), @@ -240,7 +240,7 @@ mod test_color_option { #[test] fn test_from_arg_matches_color_multiple() { - let argv = vec!["lsd", "--color", "always", "--color", "never"]; + let argv = ["lsd", "--color", "always", "--color", "never"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!( Some(ColorOption::Never), diff --git a/src/flags/date.rs b/src/flags/date.rs index 2f1195d..9f21768 100644 --- a/src/flags/date.rs +++ b/src/flags/date.rs @@ -121,21 +121,21 @@ mod test { #[test] fn test_from_arg_matches_none() { - let argv = vec!["lsd"]; + let argv = ["lsd"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!(None, DateFlag::from_arg_matches(&matches)); } #[test] fn test_from_arg_matches_date() { - let argv = vec!["lsd", "--date", "date"]; + let argv = ["lsd", "--date", "date"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!(Some(DateFlag::Date), DateFlag::from_arg_matches(&matches)); } #[test] fn test_from_arg_matches_relative() { - let argv = vec!["lsd", "--date", "relative"]; + let argv = ["lsd", "--date", "relative"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!( Some(DateFlag::Relative), @@ -145,7 +145,7 @@ mod test { #[test] fn test_from_arg_matches_format() { - let argv = vec!["lsd", "--date", "+%F"]; + let argv = ["lsd", "--date", "+%F"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!( Some(DateFlag::Formatted("%F".to_string())), @@ -156,21 +156,21 @@ mod test { #[test] #[should_panic(expected = "invalid format specifier: %J")] fn test_from_arg_matches_format_invalid() { - let argv = vec!["lsd", "--date", "+%J"]; + let argv = ["lsd", "--date", "+%J"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); DateFlag::from_arg_matches(&matches); } #[test] fn test_from_arg_matches_classic_mode() { - let argv = vec!["lsd", "--date", "date", "--classic"]; + let argv = ["lsd", "--date", "date", "--classic"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!(Some(DateFlag::Date), DateFlag::from_arg_matches(&matches)); } #[test] fn test_from_arg_matches_date_multi() { - let argv = vec!["lsd", "--date", "relative", "--date", "date"]; + let argv = ["lsd", "--date", "relative", "--date", "date"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!(Some(DateFlag::Date), DateFlag::from_arg_matches(&matches)); } @@ -268,7 +268,7 @@ mod test { #[serial_test::serial] fn test_parsing_order_arg() { std::env::set_var("TIME_STYLE", "+%R"); - let argv = vec!["lsd", "--date", "+%F"]; + let argv = ["lsd", "--date", "+%F"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); let mut config = Config::with_none(); config.date = Some("+%c".into()); @@ -282,7 +282,7 @@ mod test { #[serial_test::serial] fn test_parsing_order_env() { std::env::set_var("TIME_STYLE", "+%R"); - let argv = vec!["lsd"]; + let argv = ["lsd"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); let mut config = Config::with_none(); config.date = Some("+%c".into()); @@ -296,7 +296,7 @@ mod test { #[serial_test::serial] fn test_parsing_order_config() { std::env::set_var("TIME_STYLE", ""); - let argv = vec!["lsd"]; + let argv = ["lsd"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); let mut config = Config::with_none(); config.date = Some("+%c".into()); diff --git a/src/flags/dereference.rs b/src/flags/dereference.rs index 8c87ef9..96b0726 100644 --- a/src/flags/dereference.rs +++ b/src/flags/dereference.rs @@ -43,14 +43,14 @@ mod test { #[test] fn test_from_arg_matches_none() { - let argv = vec!["lsd"]; + let argv = ["lsd"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!(None, Dereference::from_arg_matches(&matches)); } #[test] fn test_from_arg_matches_true() { - let argv = vec!["lsd", "--dereference"]; + let argv = ["lsd", "--dereference"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!( Some(Dereference(true)), diff --git a/src/flags/display.rs b/src/flags/display.rs index f159b8e..3ebd53b 100644 --- a/src/flags/display.rs +++ b/src/flags/display.rs @@ -64,21 +64,21 @@ mod test { #[test] fn test_from_arg_matches_none() { - let argv = vec!["lsd"]; + let argv = ["lsd"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!(None, Display::from_arg_matches(&matches)); } #[test] fn test_from_arg_matches_all() { - let argv = vec!["lsd", "--all"]; + let argv = ["lsd", "--all"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!(Some(Display::All), Display::from_arg_matches(&matches)); } #[test] fn test_from_arg_matches_almost_all() { - let argv = vec!["lsd", "--almost-all"]; + let argv = ["lsd", "--almost-all"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!( Some(Display::AlmostAll), @@ -88,7 +88,7 @@ mod test { #[test] fn test_from_arg_matches_directory_only() { - let argv = vec!["lsd", "--directory-only"]; + let argv = ["lsd", "--directory-only"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!( Some(Display::DirectoryOnly), diff --git a/src/flags/header.rs b/src/flags/header.rs index 845033a..2991df4 100644 --- a/src/flags/header.rs +++ b/src/flags/header.rs @@ -44,14 +44,14 @@ mod test { #[test] fn test_from_arg_matches_none() { - let argv = vec!["lsd"]; + let argv = ["lsd"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!(None, Header::from_arg_matches(&matches)); } #[test] fn test_from_arg_matches_true() { - let argv = vec!["lsd", "--header"]; + let argv = ["lsd", "--header"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!(Some(Header(true)), Header::from_arg_matches(&matches)); } diff --git a/src/flags/hyperlink.rs b/src/flags/hyperlink.rs index b5abba6..d7b1fbc 100644 --- a/src/flags/hyperlink.rs +++ b/src/flags/hyperlink.rs @@ -70,14 +70,14 @@ mod test_hyperlink_option { #[test] fn test_from_arg_matches_none() { - let argv = vec!["lsd"]; + let argv = ["lsd"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!(None, HyperlinkOption::from_arg_matches(&matches)); } #[test] fn test_from_arg_matches_always() { - let argv = vec!["lsd", "--hyperlink", "always"]; + let argv = ["lsd", "--hyperlink", "always"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!( Some(HyperlinkOption::Always), @@ -87,7 +87,7 @@ mod test_hyperlink_option { #[test] fn test_from_arg_matches_autp() { - let argv = vec!["lsd", "--hyperlink", "auto"]; + let argv = ["lsd", "--hyperlink", "auto"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!( Some(HyperlinkOption::Auto), @@ -97,7 +97,7 @@ mod test_hyperlink_option { #[test] fn test_from_arg_matches_never() { - let argv = vec!["lsd", "--hyperlink", "never"]; + let argv = ["lsd", "--hyperlink", "never"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!( Some(HyperlinkOption::Never), @@ -107,7 +107,7 @@ mod test_hyperlink_option { #[test] fn test_from_arg_matches_classic_mode() { - let argv = vec!["lsd", "--hyperlink", "always", "--classic"]; + let argv = ["lsd", "--hyperlink", "always", "--classic"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!( Some(HyperlinkOption::Never), @@ -117,7 +117,7 @@ mod test_hyperlink_option { #[test] fn test_from_arg_matches_hyperlink_when_multi() { - let argv = vec!["lsd", "--hyperlink", "always", "--hyperlink", "never"]; + let argv = ["lsd", "--hyperlink", "always", "--hyperlink", "never"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!( Some(HyperlinkOption::Never), diff --git a/src/flags/icons.rs b/src/flags/icons.rs index 78d0fc6..c8d41bf 100644 --- a/src/flags/icons.rs +++ b/src/flags/icons.rs @@ -183,14 +183,14 @@ mod test_icon_option { #[test] fn test_from_arg_matches_none() { - let argv = vec!["lsd"]; + let argv = ["lsd"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!(None, IconOption::from_arg_matches(&matches)); } #[test] fn test_from_arg_matches_always() { - let argv = vec!["lsd", "--icon", "always"]; + let argv = ["lsd", "--icon", "always"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!( Some(IconOption::Always), @@ -200,7 +200,7 @@ mod test_icon_option { #[test] fn test_from_arg_matches_autp() { - let argv = vec!["lsd", "--icon", "auto"]; + let argv = ["lsd", "--icon", "auto"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!( Some(IconOption::Auto), @@ -210,7 +210,7 @@ mod test_icon_option { #[test] fn test_from_arg_matches_never() { - let argv = vec!["lsd", "--icon", "never"]; + let argv = ["lsd", "--icon", "never"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!( Some(IconOption::Never), @@ -220,7 +220,7 @@ mod test_icon_option { #[test] fn test_from_arg_matches_classic_mode() { - let argv = vec!["lsd", "--icon", "always", "--classic"]; + let argv = ["lsd", "--icon", "always", "--classic"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!( Some(IconOption::Never), @@ -230,7 +230,7 @@ mod test_icon_option { #[test] fn test_from_arg_matches_icon_when_multi() { - let argv = vec!["lsd", "--icon", "always", "--icon", "never"]; + let argv = ["lsd", "--icon", "always", "--icon", "never"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!( Some(IconOption::Never), @@ -299,14 +299,14 @@ mod test_icon_theme { #[test] fn test_from_arg_matches_none() { - let argv = vec!["lsd"]; + let argv = ["lsd"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!(None, IconTheme::from_arg_matches(&matches)); } #[test] fn test_from_arg_matches_fancy() { - let argv = vec!["lsd", "--icon-theme", "fancy"]; + let argv = ["lsd", "--icon-theme", "fancy"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!( Some(IconTheme::Fancy), @@ -316,7 +316,7 @@ mod test_icon_theme { #[test] fn test_from_arg_matches_unicode() { - let argv = vec!["lsd", "--icon-theme", "unicode"]; + let argv = ["lsd", "--icon-theme", "unicode"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!( Some(IconTheme::Unicode), @@ -326,7 +326,7 @@ mod test_icon_theme { #[test] fn test_from_arg_matches_icon_multi() { - let argv = vec!["lsd", "--icon-theme", "fancy", "--icon-theme", "unicode"]; + let argv = ["lsd", "--icon-theme", "fancy", "--icon-theme", "unicode"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!( Some(IconTheme::Unicode), diff --git a/src/flags/ignore_globs.rs b/src/flags/ignore_globs.rs index 6207b8a..e2b6579 100644 --- a/src/flags/ignore_globs.rs +++ b/src/flags/ignore_globs.rs @@ -141,7 +141,7 @@ mod test { #[test] fn test_configuration_from_none() { - let argv = vec!["lsd"]; + let argv = ["lsd"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert!( match IgnoreGlobs::configure_from(&matches, &Config::with_none()) { @@ -153,7 +153,7 @@ mod test { #[test] fn test_configuration_from_args() { - let argv = vec!["lsd", "--ignore-glob", ".git"]; + let argv = ["lsd", "--ignore-glob", ".git"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert!( match IgnoreGlobs::configure_from(&matches, &Config::with_none()) { @@ -165,7 +165,7 @@ mod test { #[test] fn test_configuration_from_config() { - let argv = vec!["lsd"]; + let argv = ["lsd"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); let mut c = Config::with_none(); c.ignore_globs = Some(vec![".git".into()].into()); @@ -177,7 +177,7 @@ mod test { #[test] fn test_from_arg_matches_none() { - let argv = vec!["lsd"]; + let argv = ["lsd"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert!(match IgnoreGlobs::from_arg_matches(&matches) { None => true, diff --git a/src/flags/indicators.rs b/src/flags/indicators.rs index 21df617..f07cd2e 100644 --- a/src/flags/indicators.rs +++ b/src/flags/indicators.rs @@ -44,14 +44,14 @@ mod test { #[test] fn test_from_arg_matches_none() { - let argv = vec!["lsd"]; + let argv = ["lsd"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!(None, Indicators::from_arg_matches(&matches)); } #[test] fn test_from_arg_matches_true() { - let argv = vec!["lsd", "--classify"]; + let argv = ["lsd", "--classify"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!( Some(Indicators(true)), diff --git a/src/flags/layout.rs b/src/flags/layout.rs index 1e0da49..f43f822 100644 --- a/src/flags/layout.rs +++ b/src/flags/layout.rs @@ -67,35 +67,35 @@ mod test { #[test] fn test_from_arg_matches_none() { - let argv = vec!["lsd"]; + let argv = ["lsd"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!(None, Layout::from_arg_matches(&matches)); } #[test] fn test_from_arg_matches_tree() { - let argv = vec!["lsd", "--tree"]; + let argv = ["lsd", "--tree"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!(Some(Layout::Tree), Layout::from_arg_matches(&matches)); } #[test] fn test_from_arg_matches_oneline() { - let argv = vec!["lsd", "--oneline"]; + let argv = ["lsd", "--oneline"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!(Some(Layout::OneLine), Layout::from_arg_matches(&matches)); } #[test] fn test_from_arg_matches_oneline_through_long() { - let argv = vec!["lsd", "--long"]; + let argv = ["lsd", "--long"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!(Some(Layout::OneLine), Layout::from_arg_matches(&matches)); } #[test] fn test_from_arg_matches_oneline_through_blocks() { - let argv = vec!["lsd", "--blocks", "permission,name"]; + let argv = ["lsd", "--blocks", "permission,name"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!(Some(Layout::OneLine), Layout::from_arg_matches(&matches)); } diff --git a/src/flags/permission.rs b/src/flags/permission.rs index 978dea5..551e37e 100644 --- a/src/flags/permission.rs +++ b/src/flags/permission.rs @@ -88,14 +88,14 @@ mod test { #[test] fn test_from_arg_matches_none() { - let argv = vec!["lsd"]; + let argv = ["lsd"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!(None, PermissionFlag::from_arg_matches(&matches)); } #[test] fn test_from_arg_matches_default() { - let argv = vec!["lsd", "--permission", "rwx"]; + let argv = ["lsd", "--permission", "rwx"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!( Some(PermissionFlag::Rwx), diff --git a/src/flags/recursion.rs b/src/flags/recursion.rs index 0120be7..61cadcb 100644 --- a/src/flags/recursion.rs +++ b/src/flags/recursion.rs @@ -138,21 +138,21 @@ mod test { #[test] fn test_enabled_from_arg_matches_empty() { - let argv = vec!["lsd"]; + let argv = ["lsd"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!(None, Recursion::enabled_from_arg_matches(&matches)); } #[test] fn test_enabled_from_arg_matches_true() { - let argv = vec!["lsd", "--recursive"]; + let argv = ["lsd", "--recursive"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!(Some(true), Recursion::enabled_from_arg_matches(&matches)); } #[test] fn test_enabled_from_empty_matches_and_config() { - let argv = vec!["lsd"]; + let argv = ["lsd"]; assert_eq!( false, Recursion::enabled_from( @@ -164,7 +164,7 @@ mod test { #[test] fn test_enabled_from_matches_empty_and_config_true() { - let argv = vec!["lsd"]; + let argv = ["lsd"]; let mut c = Config::with_none(); c.recursion = Some(config_file::Recursion { enabled: Some(true), @@ -178,7 +178,7 @@ mod test { #[test] fn test_enabled_from_matches_empty_and_config_false() { - let argv = vec!["lsd"]; + let argv = ["lsd"]; let mut c = Config::with_none(); c.recursion = Some(config_file::Recursion { enabled: Some(false), @@ -195,7 +195,7 @@ mod test { #[test] fn test_depth_from_arg_matches_empty() { - let argv = vec!["lsd"]; + let argv = ["lsd"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert!(match Recursion::depth_from_arg_matches(&matches) { None => true, @@ -205,7 +205,7 @@ mod test { #[test] fn test_depth_from_arg_matches_integer() { - let argv = vec!["lsd", "--depth", "42"]; + let argv = ["lsd", "--depth", "42"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert!(match Recursion::depth_from_arg_matches(&matches) { None => false, @@ -220,7 +220,7 @@ mod test { #[test] fn test_depth_from_arg_matches_depth_multi() { - let argv = vec!["lsd", "--depth", "4", "--depth", "2"]; + let argv = ["lsd", "--depth", "4", "--depth", "2"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert!(match Recursion::depth_from_arg_matches(&matches) { None => false, @@ -235,7 +235,7 @@ mod test { #[test] fn test_depth_from_arg_matches_neg_int() { - let argv = vec!["lsd", "--depth", "\\-42"]; + let argv = ["lsd", "--depth", "\\-42"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert!(match Recursion::depth_from_arg_matches(&matches) { None => false, @@ -250,7 +250,7 @@ mod test { #[test] fn test_depth_from_arg_matches_non_int() { - let argv = vec!["lsd", "--depth", "foo"]; + let argv = ["lsd", "--depth", "foo"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert!(match Recursion::depth_from_arg_matches(&matches) { None => false, @@ -265,7 +265,7 @@ mod test { #[test] fn test_depth_from_config_none_max() { - let argv = vec!["lsd"]; + let argv = ["lsd"]; assert_eq!( usize::max_value(), Recursion::depth_from( @@ -278,7 +278,7 @@ mod test { #[test] fn test_depth_from_config_pos_integer() { - let argv = vec!["lsd"]; + let argv = ["lsd"]; let mut c = Config::with_none(); c.recursion = Some(config_file::Recursion { enabled: None, diff --git a/src/flags/size.rs b/src/flags/size.rs index 9f40d6a..c10820a 100644 --- a/src/flags/size.rs +++ b/src/flags/size.rs @@ -89,14 +89,14 @@ mod test { #[test] fn test_from_arg_matches_none() { - let argv = vec!["lsd"]; + let argv = ["lsd"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!(None, SizeFlag::from_arg_matches(&matches)); } #[test] fn test_from_arg_matches_default() { - let argv = vec!["lsd", "--size", "default"]; + let argv = ["lsd", "--size", "default"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!( Some(SizeFlag::Default), diff --git a/src/flags/sorting.rs b/src/flags/sorting.rs index a791f93..e16c411 100644 --- a/src/flags/sorting.rs +++ b/src/flags/sorting.rs @@ -221,14 +221,14 @@ mod test_sort_column { #[test] fn test_from_arg_matches_none() { - let argv = vec!["lsd"]; + let argv = ["lsd"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!(None, SortColumn::from_arg_matches(&matches)); } #[test] fn test_from_arg_matches_extension() { - let argv = vec!["lsd", "--extensionsort"]; + let argv = ["lsd", "--extensionsort"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!( Some(SortColumn::Extension), @@ -238,7 +238,7 @@ mod test_sort_column { #[test] fn test_from_arg_matches_time() { - let argv = vec!["lsd", "--timesort"]; + let argv = ["lsd", "--timesort"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!( Some(SortColumn::Time), @@ -248,7 +248,7 @@ mod test_sort_column { #[test] fn test_from_arg_matches_size() { - let argv = vec!["lsd", "--sizesort"]; + let argv = ["lsd", "--sizesort"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!( Some(SortColumn::Size), @@ -258,7 +258,7 @@ mod test_sort_column { #[test] fn test_from_arg_matches_version() { - let argv = vec!["lsd", "--versionsort"]; + let argv = ["lsd", "--versionsort"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!( Some(SortColumn::Version), @@ -268,7 +268,7 @@ mod test_sort_column { #[test] fn test_from_arg_matches_no_sort() { - let argv = vec!["lsd", "--no-sort"]; + let argv = ["lsd", "--no-sort"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!( Some(SortColumn::None), @@ -278,35 +278,35 @@ mod test_sort_column { #[test] fn test_from_arg_matches_sort() { - let argv = vec!["lsd", "--sort", "time"]; + let argv = ["lsd", "--sort", "time"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!( Some(SortColumn::Time), SortColumn::from_arg_matches(&matches) ); - let argv = vec!["lsd", "--sort", "size"]; + let argv = ["lsd", "--sort", "size"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!( Some(SortColumn::Size), SortColumn::from_arg_matches(&matches) ); - let argv = vec!["lsd", "--sort", "extension"]; + let argv = ["lsd", "--sort", "extension"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!( Some(SortColumn::Extension), SortColumn::from_arg_matches(&matches) ); - let argv = vec!["lsd", "--sort", "version"]; + let argv = ["lsd", "--sort", "version"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!( Some(SortColumn::Version), SortColumn::from_arg_matches(&matches) ); - let argv = vec!["lsd", "--sort", "none"]; + let argv = ["lsd", "--sort", "none"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!( Some(SortColumn::None), @@ -316,7 +316,7 @@ mod test_sort_column { #[test] fn test_multi_sort() { - let argv = vec!["lsd", "--sort", "size", "--sort", "time"]; + let argv = ["lsd", "--sort", "size", "--sort", "time"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!( Some(SortColumn::Time), @@ -326,7 +326,7 @@ mod test_sort_column { #[test] fn test_multi_sort_use_last() { - let argv = vec!["lsd", "--sort", "size", "-t", "-S", "-X", "--sort", "time"]; + let argv = ["lsd", "--sort", "size", "-t", "-S", "-X", "--sort", "time"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!( Some(SortColumn::Time), @@ -417,14 +417,14 @@ mod test_sort_order { #[test] fn test_from_arg_matches_none() { - let argv = vec!["lsd"]; + let argv = ["lsd"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!(None, SortOrder::from_arg_matches(&matches)); } #[test] fn test_from_arg_matches_reverse() { - let argv = vec!["lsd", "--reverse"]; + let argv = ["lsd", "--reverse"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!( Some(SortOrder::Reverse), @@ -497,14 +497,14 @@ mod test_dir_grouping { #[test] fn test_from_arg_matches_none() { - let argv = vec!["lsd"]; + let argv = ["lsd"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!(None, DirGrouping::from_arg_matches(&matches)); } #[test] fn test_from_arg_matches_first() { - let argv = vec!["lsd", "--group-dirs", "first"]; + let argv = ["lsd", "--group-dirs", "first"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!( Some(DirGrouping::First), @@ -514,7 +514,7 @@ mod test_dir_grouping { #[test] fn test_from_arg_matches_last() { - let argv = vec!["lsd", "--group-dirs", "last"]; + let argv = ["lsd", "--group-dirs", "last"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!( Some(DirGrouping::Last), @@ -524,7 +524,7 @@ mod test_dir_grouping { #[test] fn test_from_arg_matches_explicit_none() { - let argv = vec!["lsd", "--group-dirs", "none"]; + let argv = ["lsd", "--group-dirs", "none"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!( Some(DirGrouping::None), @@ -534,7 +534,7 @@ mod test_dir_grouping { #[test] fn test_from_arg_matches_classic_mode() { - let argv = vec!["lsd", "--group-dirs", "first", "--classic"]; + let argv = ["lsd", "--group-dirs", "first", "--classic"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!( Some(DirGrouping::None), @@ -544,7 +544,7 @@ mod test_dir_grouping { #[test] fn test_from_arg_matches_group_dirs_multi() { - let argv = vec!["lsd", "--group-dirs", "first", "--group-dirs", "last"]; + let argv = ["lsd", "--group-dirs", "first", "--group-dirs", "last"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!( Some(DirGrouping::Last), @@ -554,7 +554,7 @@ mod test_dir_grouping { #[test] fn test_from_arg_matches_group_directories_first() { - let argv = vec!["lsd", "--group-directories-first"]; + let argv = ["lsd", "--group-directories-first"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!( Some(DirGrouping::First), diff --git a/src/flags/symlinks.rs b/src/flags/symlinks.rs index c2960a8..6afc5c4 100644 --- a/src/flags/symlinks.rs +++ b/src/flags/symlinks.rs @@ -44,14 +44,14 @@ mod test { #[test] fn test_from_arg_matches_none() { - let argv = vec!["lsd"]; + let argv = ["lsd"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!(None, NoSymlink::from_arg_matches(&matches)); } #[test] fn test_from_arg_matches_true() { - let argv = vec!["lsd", "--no-symlink"]; + let argv = ["lsd", "--no-symlink"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!(Some(NoSymlink(true)), NoSymlink::from_arg_matches(&matches)); } diff --git a/src/flags/total_size.rs b/src/flags/total_size.rs index 3b5ab6f..7637052 100644 --- a/src/flags/total_size.rs +++ b/src/flags/total_size.rs @@ -44,14 +44,14 @@ mod test { #[test] fn test_from_arg_matches_none() { - let argv = vec!["lsd"]; + let argv = ["lsd"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!(None, TotalSize::from_arg_matches(&matches)); } #[test] fn test_from_arg_matches_true() { - let argv = vec!["lsd", "--total-size"]; + let argv = ["lsd", "--total-size"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!(Some(TotalSize(true)), TotalSize::from_arg_matches(&matches)); } diff --git a/src/meta/symlink.rs b/src/meta/symlink.rs index bb9437c..b26c971 100644 --- a/src/meta/symlink.rs +++ b/src/meta/symlink.rs @@ -86,7 +86,7 @@ mod tests { target: Some("/target".to_string()), valid: true, }; - let argv = vec!["lsd"]; + let argv = ["lsd"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!( format!("{}", " ⇒ /target"), @@ -104,7 +104,7 @@ mod tests { target: Some("/target".to_string()), valid: false, }; - let argv = vec!["lsd"]; + let argv = ["lsd"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!( format!("{}", " ⇒ /target"), @@ -122,7 +122,7 @@ mod tests { target: Some("/target".to_string()), valid: false, }; - let argv = vec!["lsd"]; + let argv = ["lsd"]; let matches = app::build().get_matches_from_safe(argv).unwrap(); assert_eq!( format!("{}", " ⇒ \u{1b}[38;5;124m/target\u{1b}[39m"),