From 5bf4209bd138faf76e3bd316fdfa128a08f2bb2e Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Tue, 28 Apr 2026 21:37:34 +0800 Subject: Apply clippy suggestions for code simplification --- mling/src/cli/list.rs | 4 +--- mling/src/cli/namespace_mgr.rs | 8 ++++---- mling/src/cli/read.rs | 4 +--- 3 files changed, 6 insertions(+), 10 deletions(-) (limited to 'mling/src/cli') diff --git a/mling/src/cli/list.rs b/mling/src/cli/list.rs index faf1866..a0c68a0 100644 --- a/mling/src/cli/list.rs +++ b/mling/src/cli/list.rs @@ -109,9 +109,7 @@ fn print_list(title: String, list: Vec, r: &mut RenderResult) { r_println!("{}", title); - let mut i = 1; - for namespace in list.iter() { + for (i, namespace) in (1..).zip(list.iter()) { r_println!(" {}. {}", i.to_string(), namespace.bold()); - i += 1; } } diff --git a/mling/src/cli/namespace_mgr.rs b/mling/src/cli/namespace_mgr.rs index 9781040..4f70c15 100644 --- a/mling/src/cli/namespace_mgr.rs +++ b/mling/src/cli/namespace_mgr.rs @@ -26,7 +26,7 @@ pub(crate) fn comp_trust(ctx: &ShellContext) -> Suggest { return Suggest::Suggest( list_namespaces(false, true, true) .into_iter() - .map(|i| SuggestItem::new(i)) + .map(SuggestItem::new) .collect::>(), ); } @@ -39,7 +39,7 @@ pub(crate) fn comp_untrust(ctx: &ShellContext) -> Suggest { return Suggest::Suggest( list_namespaces(true, false, true) .into_iter() - .map(|i| SuggestItem::new(i)) + .map(SuggestItem::new) .collect::>(), ); } @@ -61,7 +61,7 @@ pub(crate) fn comp_set_trust(ctx: &ShellContext) -> Suggest { return Suggest::Suggest( list_namespaces(true, true, true) .into_iter() - .map(|i| SuggestItem::new(i)) + .map(SuggestItem::new) .collect::>(), ); } @@ -74,7 +74,7 @@ pub(crate) fn comp_remove_namespace(ctx: &ShellContext) -> Suggest { return Suggest::Suggest( list_namespaces(true, true, true) .into_iter() - .map(|i| SuggestItem::new(i)) + .map(SuggestItem::new) .collect::>(), ); } diff --git a/mling/src/cli/read.rs b/mling/src/cli/read.rs index 8717932..3bd9fc2 100644 --- a/mling/src/cli/read.rs +++ b/mling/src/cli/read.rs @@ -64,14 +64,12 @@ pub(crate) fn render_dir(prev: ResultDir) { #[renderer] pub(crate) fn render_binaries(prev: ResultBinaries) { - let mut i = 1; - for item in prev.bin.iter() { + for (i, item) in (1..).zip(prev.bin.iter()) { r_println!( "{}. {} ({})", i.to_string(), item.name.bold(), item.path.to_string_lossy().underline().bright_cyan() ); - i += 1; } } -- cgit