diff --git a/src/config.rs b/src/config.rs index 0b8fa820..01861a36 100644 --- a/src/config.rs +++ b/src/config.rs @@ -141,7 +141,7 @@ where fn from_config(config: &'a Value) -> Option { let mut hm = Self::default(); - for (x, y) in config.as_table()?.iter() { + for (x, y) in config.as_table()? { hm.insert(x.clone(), T::from_config(y)?); } @@ -157,7 +157,7 @@ where fn from_config(config: &'a Value) -> Option { let mut im = Self::default(); - for (x, y) in config.as_table()?.iter() { + for (x, y) in config.as_table()? { im.insert(x.clone(), T::from_config(y)?); } diff --git a/src/configs/starship_root.rs b/src/configs/starship_root.rs index d6dc4617..b4478db3 100644 --- a/src/configs/starship_root.rs +++ b/src/configs/starship_root.rs @@ -122,7 +122,7 @@ impl<'a> ModuleConfig<'a> for StarshipRootConfig<'a> { "env_var", ] .iter() - .chain(ALL_MODULES.iter()) + .chain(ALL_MODULES) .filter_map(|field| { let score = strsim::jaro_winkler(unknown, field); (score > 0.8).then(|| (score, field)) diff --git a/src/modules/directory.rs b/src/modules/directory.rs index ab903105..adf68836 100644 --- a/src/modules/directory.rs +++ b/src/modules/directory.rs @@ -253,7 +253,7 @@ fn real_path>(path: P) -> PathBuf { /// substitutions, in order, on the path. Any non-pair of strings is ignored. fn substitute_path(dir_string: String, substitutions: &IndexMap) -> String { let mut substituted_dir = dir_string; - for substitution_pair in substitutions.iter() { + for substitution_pair in substitutions { substituted_dir = substituted_dir.replace(substitution_pair.0, substitution_pair.1); } substituted_dir diff --git a/src/modules/dotnet.rs b/src/modules/dotnet.rs index 4683cc76..5bfca482 100644 --- a/src/modules/dotnet.rs +++ b/src/modules/dotnet.rs @@ -186,7 +186,7 @@ fn try_find_nearby_global_json(current_dir: &Path, repo_root: Option<&Path>) -> // Check the parent directory, or otherwise the repository root, for a global.json let mut check_dirs = parent_dir .iter() - .chain(repo_root.iter()) + .chain(&repo_root) .copied() // Copies the reference, not the Path itself .collect::>(); diff --git a/src/modules/kubernetes.rs b/src/modules/kubernetes.rs index 13835065..e20bb876 100644 --- a/src/modules/kubernetes.rs +++ b/src/modules/kubernetes.rs @@ -429,7 +429,7 @@ users: [] .path(dir.path()) .env( "KUBECONFIG", - env::join_paths([&filename_cc, &filename_ctx].iter()) + env::join_paths([&filename_cc, &filename_ctx]) .unwrap() .to_string_lossy(), ) @@ -444,7 +444,7 @@ users: [] .path(dir.path()) .env( "KUBECONFIG", - env::join_paths([&filename_ctx, &filename_cc].iter()) + env::join_paths([&filename_ctx, &filename_cc]) .unwrap() .to_string_lossy(), ) diff --git a/src/modules/status.rs b/src/modules/status.rs index 6436267f..a0056329 100644 --- a/src/modules/status.rs +++ b/src/modules/status.rs @@ -287,7 +287,7 @@ mod tests { None, ]; - for (status, name) in exit_values.iter().zip(exit_values_name.iter()) { + for (status, name) in exit_values.iter().zip(&exit_values_name) { let expected = name.map(std::string::ToString::to_string); let actual = ModuleRenderer::new("status") .config(toml::toml! { @@ -314,7 +314,7 @@ mod tests { None, ]; - for (status, name) in exit_values.iter().zip(exit_values_name.iter()) { + for (status, name) in exit_values.iter().zip(&exit_values_name) { let expected = name.map(std::string::ToString::to_string); let actual = ModuleRenderer::new("status") .config(toml::toml! { @@ -343,7 +343,7 @@ mod tests { Some("-3"), ]; - for (status, name) in exit_values.iter().zip(exit_values_name.iter()) { + for (status, name) in exit_values.iter().zip(&exit_values_name) { let expected = name.map(std::string::ToString::to_string); let actual = ModuleRenderer::new("status") .config(toml::toml! { @@ -362,7 +362,7 @@ mod tests { let exit_values = [1, 126, 127, 130, 131]; let exit_values_name = ["🔴", "🚫", "🔍", "🧱", "⚡"]; - for (status, name) in exit_values.iter().zip(exit_values_name.iter()) { + for (status, name) in exit_values.iter().zip(&exit_values_name) { let expected = Some((*name).to_string()); let actual = ModuleRenderer::new("status") .config(toml::toml! { @@ -388,7 +388,7 @@ mod tests { let exit_values = [1, 126, 127, 130, 131]; let exit_values_name = ["🔴", "🚫", "🔍", "🔴", "🔴"]; - for (status, name) in exit_values.iter().zip(exit_values_name.iter()) { + for (status, name) in exit_values.iter().zip(&exit_values_name) { let expected = Some((*name).to_string()); let actual = ModuleRenderer::new("status") .config(toml::toml! { @@ -424,7 +424,7 @@ mod tests { "PSF 🔴=🔴 🔴 🔴", ]; - for (status, rendered) in exit_values.iter().zip(exit_values_rendered.iter()) { + for (status, rendered) in exit_values.iter().zip(&exit_values_rendered) { let main_exit_code = status[0]; let pipe_exit_code = &status[1..]; @@ -468,7 +468,7 @@ mod tests { "PSF 🔴=🔴1 🔴1 🔴1", ]; - for (status, rendered) in exit_values.iter().zip(exit_values_rendered.iter()) { + for (status, rendered) in exit_values.iter().zip(&exit_values_rendered) { let main_exit_code = status[0]; let pipe_exit_code = &status[1..]; @@ -521,7 +521,7 @@ mod tests { let exit_values = [[130, 126, 131, 127], [1, 1, 1, 1]]; let exit_values_rendered = ["F 🧱", "F 🔴"]; - for (status, rendered) in exit_values.iter().zip(exit_values_rendered.iter()) { + for (status, rendered) in exit_values.iter().zip(&exit_values_rendered) { let main_exit_code = status[0]; let pipe_exit_code = &status[1..]; @@ -561,7 +561,7 @@ mod tests { "PSF 1ERROR=🟢|🟢|🟢|🔴30|🔍|🚫|🔴3|⚡|🟢|⚡|🟢|🔴", ]; - for (status, rendered) in exit_values.iter().zip(exit_values_rendered.iter()) { + for (status, rendered) in exit_values.iter().zip(&exit_values_rendered) { let main_exit_code = status[0]; let pipe_exit_code = &status[1..]; diff --git a/src/modules/utils/directory_win.rs b/src/modules/utils/directory_win.rs index 381a4232..53253c7d 100644 --- a/src/modules/utils/directory_win.rs +++ b/src/modules/utils/directory_win.rs @@ -1,6 +1,5 @@ extern crate winapi; -use std::iter; use std::mem; use std::os::windows::ffi::OsStrExt; use std::path::Path; @@ -22,11 +21,7 @@ use winapi::um::winnt::{ /// the current process access token and directory's security descriptor. /// Does not work for network drives and always returns true pub fn is_write_allowed(folder_path: &Path) -> std::result::Result { - let folder_name: Vec = folder_path - .as_os_str() - .encode_wide() - .chain(iter::once(0)) - .collect(); + let folder_name: Vec = folder_path.as_os_str().encode_wide().chain([0]).collect(); if is_network_path(&folder_name) { log::info!( diff --git a/src/print.rs b/src/print.rs index 295a9886..6ddddb41 100644 --- a/src/print.rs +++ b/src/print.rs @@ -300,13 +300,13 @@ fn compute_modules<'a>(context: &'a Context) -> Vec> { for module in &modules { // Manually add all modules if `$all` is encountered if module == "all" { - for module in PROMPT_ORDER.iter() { + for module in PROMPT_ORDER { let modules = handle_module(module, context, &modules); - prompt_order.extend(modules.into_iter()); + prompt_order.extend(modules); } } else { let modules = handle_module(module, context, &modules); - prompt_order.extend(modules.into_iter()); + prompt_order.extend(modules); } } diff --git a/starship_module_config_derive/src/lib.rs b/starship_module_config_derive/src/lib.rs index 40d4301b..03b32a5e 100644 --- a/starship_module_config_derive/src/lib.rs +++ b/starship_module_config_derive/src/lib.rs @@ -20,7 +20,7 @@ fn impl_module_config(dinput: DeriveInput) -> proc_macro::TokenStream { let mut load_tokens = quote! {}; let mut fields = quote! {}; - for field in fields_named.named.iter() { + for field in &fields_named.named { let ident = field.ident.as_ref().unwrap(); let new_load_tokens = quote! {