From 9001559102bfb07ed03b6318c6b23373004c5eaa Mon Sep 17 00:00:00 2001 From: Lucas Nogueira Date: Thu, 28 Aug 2025 17:57:26 -0300 Subject: [PATCH] chore: clippy --- build.rs | 10 ++------- src/android/adb/device_list.rs | 2 +- src/android/cli.rs | 3 +-- src/android/config.rs | 11 +++------ src/android/jnilibs.rs | 11 +++++---- src/android/project.rs | 15 ++++++------- src/android/source_props.rs | 2 +- src/apple/cli.rs | 18 +++++++-------- src/apple/config/mod.rs | 8 +++---- src/apple/config/raw.rs | 10 ++++----- src/apple/deps/mod.rs | 2 +- src/apple/deps/xcode_plugin.rs | 24 +++++++++----------- src/apple/device/mod.rs | 2 +- src/apple/mod.rs | 2 +- src/apple/project.rs | 2 +- src/bicycle/mod.rs | 2 +- src/bin/cargo-mobile.rs | 4 ++-- src/config/app/identifier.rs | 11 ++++----- src/config/app/lib_name.rs | 20 +++++++---------- src/config/app/mod.rs | 2 +- src/config/app/name.rs | 20 +++++++---------- src/config/app/raw.rs | 23 +++++++++---------- src/device.rs | 2 +- src/doctor/section/android.rs | 4 ++-- src/doctor/section/apple.rs | 36 ++++++++++++------------------ src/doctor/section/cargo_mobile.rs | 12 +++++----- src/doctor/section/device_list.rs | 4 ++-- src/init.rs | 6 ++--- src/project.rs | 3 +-- src/templating/filter.rs | 3 +-- src/templating/init.rs | 4 ++-- src/templating/mod.rs | 8 +++---- src/update.rs | 20 ++++++++--------- src/util/cli.rs | 10 ++++----- src/util/git/repo.rs | 18 +++++++-------- src/util/git/submodule.rs | 4 ++-- src/util/ln.rs | 4 ++-- src/util/mod.rs | 22 +++++++++--------- src/util/path.rs | 16 +++++-------- src/util/prompt.rs | 8 +++---- 40 files changed, 170 insertions(+), 218 deletions(-) diff --git a/build.rs b/build.rs index 72929a0..86c4599 100644 --- a/build.rs +++ b/build.rs @@ -33,16 +33,10 @@ fn main() { Ok(output) => { let msg = String::from_utf8_lossy(&output.stdout).to_string(); if let Err(err) = std::fs::write(install_dir.join("commit"), msg) { - println!( - "cargo:warning=failed to write current commit message: {}", - err - ) + println!("cargo:warning=failed to write current commit message: {err}") } } - Err(err) => println!( - "cargo:warning=failed to get current commit message: {}", - err - ), + Err(err) => println!("cargo:warning=failed to get current commit message: {err}"), } // Copy templates diff --git a/src/android/adb/device_list.rs b/src/android/adb/device_list.rs index 1048e8b..956c585 100644 --- a/src/android/adb/device_list.rs +++ b/src/android/adb/device_list.rs @@ -90,7 +90,7 @@ mod test { )] fn test_adb_output_regex(input: &str, devices: Vec<&'static str>) { let regex = regex_multi_line!(ADB_DEVICE_REGEX); - println!("{}", input); + println!("{input}"); let captures = regex .captures_iter(input) .map(|x| x.get(1).unwrap().as_str()) diff --git a/src/android/cli.rs b/src/android/cli.rs index 9e79c3a..fb34c70 100644 --- a/src/android/cli.rs +++ b/src/android/cli.rs @@ -151,8 +151,7 @@ impl Reportable for Error { Self::ProjectDirAbsent { project_dir } => Report::action_request( "Please run `cargo mobile init` and try again!", format!( - "Android Studio project directory {:?} doesn't exist.", - project_dir + "Android Studio project directory {project_dir:?} doesn't exist." ), ), Self::OpenFailed(err) => Report::error("Failed to open project in Android Studio", err), diff --git a/src/android/config.rs b/src/android/config.rs index c29f325..f8e41c1 100644 --- a/src/android/config.rs +++ b/src/android/config.rs @@ -145,20 +145,15 @@ impl Display for ProjectDirInvalid { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { Self::NormalizationFailed { project_dir, cause } => { - write!(f, "{:?} couldn't be normalized: {}", project_dir, cause) + write!(f, "{project_dir:?} couldn't be normalized: {cause}") } Self::OutsideOfAppRoot { project_dir, root_dir, - } => write!( - f, - "{:?} is outside of the app root {:?}", - project_dir, root_dir, - ), + } => write!(f, "{project_dir:?} is outside of the app root {root_dir:?}",), Self::ContainsSpaces { project_dir } => write!( f, - "{:?} contains spaces, which the NDK is remarkably intolerant of", - project_dir + "{project_dir:?} contains spaces, which the NDK is remarkably intolerant of" ), } } diff --git a/src/android/jnilibs.rs b/src/android/jnilibs.rs index e565a33..6ebd524 100644 --- a/src/android/jnilibs.rs +++ b/src/android/jnilibs.rs @@ -33,17 +33,16 @@ impl Reportable for RemoveBrokenLinksError { fn report(&self) -> Report { match self { Self::ReadDir { dir, source } => Report::error( - format!("Failed to list contents of jniLibs directory {:?}", dir), + format!("Failed to list contents of jniLibs directory {dir:?}"), source, ), Self::Entry { dir, source } => Report::error( - format!("Failed to get entry in jniLibs directory {:?}", dir), - source, - ), - Self::Remove { path, source } => Report::error( - format!("Failed to remove broken symlink {:?}", path), + format!("Failed to get entry in jniLibs directory {dir:?}"), source, ), + Self::Remove { path, source } => { + Report::error(format!("Failed to remove broken symlink {path:?}"), source) + } } } } diff --git a/src/android/project.rs b/src/android/project.rs index d20489e..410c7c8 100644 --- a/src/android/project.rs +++ b/src/android/project.rs @@ -61,14 +61,14 @@ impl Reportable for Error { Report::error("Android template processing failed", err) } Self::DirectoryCreationFailed { path, cause } => Report::error( - format!("Failed to create Android assets directory at {:?}", path), + format!("Failed to create Android assets directory at {path:?}"), cause, ), Self::DirectoryReadFailed { path, cause } => { - Report::error(format!("Failed to read directory at {:?}", path), cause) + Report::error(format!("Failed to read directory at {path:?}"), cause) } Self::DirectoryRemoveFailed { path, cause } => Report::error( - format!("Failed to remove directory directory at {:?}", path), + format!("Failed to remove directory directory at {path:?}"), cause, ), Self::AssetDirSymlinkFailed(err) => { @@ -77,12 +77,11 @@ impl Reportable for Error { Self::DotCargoGenFailed(err) => { Report::error("Failed to generate Android cargo config", err) } - Self::FileCopyFailed { src, dest, cause } => Report::error( - format!("Failed to copy file at {:?} to {:?}", src, dest), - cause, - ), + Self::FileCopyFailed { src, dest, cause } => { + Report::error(format!("Failed to copy file at {src:?} to {dest:?}"), cause) + } Self::AssetSourceInvalid(src) => Report::error( - format!("Asset source at {:?} invalid", src), + format!("Asset source at {src:?} invalid"), "Asset sources must be either a directory or a file", ), } diff --git a/src/android/source_props.rs b/src/android/source_props.rs index 9339288..805f1cd 100644 --- a/src/android/source_props.rs +++ b/src/android/source_props.rs @@ -32,7 +32,7 @@ impl Display for Revision { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "{}", self.triple)?; if let Some(beta) = self.beta { - write!(f, "-beta{}", beta)?; + write!(f, "-beta{beta}")?; } Ok(()) } diff --git a/src/apple/cli.rs b/src/apple/cli.rs index 1101a00..7adaaee 100644 --- a/src/apple/cli.rs +++ b/src/apple/cli.rs @@ -188,7 +188,7 @@ impl Reportable for Error { Self::Unsupported => Report::error("iOS is marked as unsupported in your Cargo.toml metadata", "If your project should support Android, modify your Cargo.toml, then run `cargo mobile init` and try again."), Self::ProjectDirAbsent { project_dir } => Report::action_request( "Please run `cargo mobile init` and try again!", - format!("Xcode project directory {:?} doesn't exist.", project_dir), + format!("Xcode project directory {project_dir:?} doesn't exist."), ), Self::OpenFailed(err) => Report::error("Failed to open project in Xcode", err), Self::CheckFailed(err) => err.report(), @@ -201,19 +201,19 @@ impl Reportable for Error { Self::CargoEnvFailed(err) => Report::error("Failed to load cargo env profile", err), Self::SdkRootInvalid { sdk_root } => Report::error( "SDK root provided by Xcode was invalid", - format!("{:?} doesn't exist or isn't a directory", sdk_root), + format!("{sdk_root:?} doesn't exist or isn't a directory"), ), Self::IncludeDirInvalid { include_dir } => Report::error( "Include dir was invalid", - format!("{:?} doesn't exist or isn't a directory", include_dir), + format!("{include_dir:?} doesn't exist or isn't a directory"), ), Self::MacosSdkRootInvalid { macos_sdk_root } => Report::error( "macOS SDK root was invalid", - format!("{:?} doesn't exist or isn't a directory", macos_sdk_root), + format!("{macos_sdk_root:?} doesn't exist or isn't a directory"), ), Self::ArchInvalid { arch } => Report::error( "Arch specified by Xcode was invalid", - format!("{:?} isn't a known arch", arch), + format!("{arch:?} isn't a known arch"), ), Self::CompileLibFailed(err) => err.report(), Self::PodCommandFailed(err) => Report::error("pod command failed", err), @@ -484,9 +484,9 @@ impl Exec for Input { "x86_64" => ("x86_64_apple_ios", "x86_64-apple-ios"), _ => return Err(Error::ArchInvalid { arch }), }; - let cflags = format!("CFLAGS_{}", triple); - let cxxflags = format!("CFLAGS_{}", triple); - let objc_include_path = format!("OBJC_INCLUDE_PATH_{}", triple); + let cflags = format!("CFLAGS_{triple}"); + let cxxflags = format!("CFLAGS_{triple}"); + let objc_include_path = format!("OBJC_INCLUDE_PATH_{triple}"); let mut target_env = host_env.clone(); target_env.insert(cflags.as_ref(), isysroot.as_ref()); target_env.insert(cxxflags.as_ref(), isysroot.as_ref()); @@ -532,7 +532,7 @@ impl Exec for Input { } // Copy static lib .a to Xcode Project - if rust_triple.starts_with(&"aarch64-apple-ios") { + if rust_triple.starts_with("aarch64-apple-ios") { std::fs::create_dir_all(format!( "Sources/{rust_triple}/{}", profile.as_str() diff --git a/src/apple/config/mod.rs b/src/apple/config/mod.rs index a798a1a..97abd6c 100644 --- a/src/apple/config/mod.rs +++ b/src/apple/config/mod.rs @@ -194,16 +194,14 @@ impl Display for ProjectDirInvalid { match self { Self::NormalizationFailed { project_dir, cause } => write!( f, - "Xcode project dir {:?} couldn't be normalized: {}", - project_dir, cause + "Xcode project dir {project_dir:?} couldn't be normalized: {cause}" ), Self::OutsideOfAppRoot { project_dir, root_dir, } => write!( f, - "Xcode project dir {:?} is outside of the app root dir {:?}", - project_dir, root_dir, + "Xcode project dir {project_dir:?} is outside of the app root dir {root_dir:?}", ), } } @@ -388,7 +386,7 @@ impl Config { } pub fn ipa_path(&self) -> Result { - let path = |tail: &str| self.export_dir().join(format!("{}.ipa", tail)); + let path = |tail: &str| self.export_dir().join(format!("{tail}.ipa")); let old = path(&self.scheme()); // It seems like the format changed recently? let new = path(self.app.stylized_name()); diff --git a/src/apple/config/raw.rs b/src/apple/config/raw.rs index c94744a..6e9a606 100644 --- a/src/apple/config/raw.rs +++ b/src/apple/config/raw.rs @@ -15,7 +15,7 @@ impl Display for DetectError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { Self::DeveloperTeamLookupFailed(err) => { - write!(f, "Failed to find Apple developer teams: {}", err) + write!(f, "Failed to find Apple developer teams: {err}") } } } @@ -31,10 +31,10 @@ impl Display for PromptError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { Self::DeveloperTeamLookupFailed(err) => { - write!(f, "Failed to find Apple developer teams: {}", err) + write!(f, "Failed to find Apple developer teams: {err}") } Self::DeveloperTeamPromptFailed(err) => { - write!(f, "Failed to prompt for Apple developer team: {}", err) + write!(f, "Failed to prompt for Apple developer team: {err}") } } } @@ -50,7 +50,7 @@ fn value_to_string(value: &PlistValue) -> String { .map(value_to_string) .collect::>() .join(","); - format!("[{}]", string) + format!("[{string}]") } PlistValue::Dictionary(dict) => dictionary_to_string(dict), } @@ -67,7 +67,7 @@ fn dictionary_to_string(dict: &PlistDictionary) -> String { .map(|pair| pair_to_string(&pair.0.key, &pair.0.value)) .collect::>() .join(","); - format!("{{{}}}", joint) + format!("{{{joint}}}") } #[derive(Clone, Debug, Deserialize)] diff --git a/src/apple/deps/mod.rs b/src/apple/deps/mod.rs index 9b0169c..1985ebb 100644 --- a/src/apple/deps/mod.rs +++ b/src/apple/deps/mod.rs @@ -97,7 +97,7 @@ impl GemCache { let command = if self.contains(package)? { "gem update" } else { - println!("`sudo` is required to install {} using gem", package); + println!("`sudo` is required to install {package} using gem"); "sudo gem install" }; duct::cmd(command, [package]) diff --git a/src/apple/deps/xcode_plugin.rs b/src/apple/deps/xcode_plugin.rs index f32d02a..4b81980 100644 --- a/src/apple/deps/xcode_plugin.rs +++ b/src/apple/deps/xcode_plugin.rs @@ -30,27 +30,25 @@ pub enum Error { impl Display for Error { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - Self::NoHomeDir(err) => write!(f, "{}", err), - Self::XcodeSelectFailed(err) => write!(f, "Failed to get path to Xcode.app: {}", err), - Self::StatusFailed(err) => write!(f, "{}", err), - Self::UpdateFailed(err) => write!(f, "{}", err), - Self::UuidLookupFailed(err) => write!(f, "Failed to lookup Xcode UUID: {}", err), + Self::NoHomeDir(err) => write!(f, "{err}"), + Self::XcodeSelectFailed(err) => write!(f, "Failed to get path to Xcode.app: {err}"), + Self::StatusFailed(err) => write!(f, "{err}"), + Self::UpdateFailed(err) => write!(f, "{err}"), + Self::UuidLookupFailed(err) => write!(f, "Failed to lookup Xcode UUID: {err}"), Self::PlistReadFailed { path, cause } => { - write!(f, "Failed to read plist at {:?}: {}", path, cause) + write!(f, "Failed to read plist at {path:?}: {cause}") } Self::PluginsDirCreationFailed { path, cause } => write!( f, - "Failed to create Xcode plugins directory {:?}: {}", - path, cause + "Failed to create Xcode plugins directory {path:?}: {cause}" ), - Self::PluginCopyFailed(err) => write!(f, "Failed to copy Xcode plugin: {}", err), + Self::PluginCopyFailed(err) => write!(f, "Failed to copy Xcode plugin: {err}"), Self::SpecDirCreationFailed { path, cause } => write!( f, - "Failed to create Xcode language spec directory {:?}: {}", - path, cause + "Failed to create Xcode language spec directory {path:?}: {cause}" ), - Self::SpecCopyFailed(err) => write!(f, "Failed to copy language spec: {}", err), - Self::MetaCopyFailed(err) => write!(f, "Failed to copy language metadata: {}", err), + Self::SpecCopyFailed(err) => write!(f, "Failed to copy language spec: {err}"), + Self::MetaCopyFailed(err) => write!(f, "Failed to copy language metadata: {err}"), } } } diff --git a/src/apple/device/mod.rs b/src/apple/device/mod.rs index 5c5b918..fa1910f 100644 --- a/src/apple/device/mod.rs +++ b/src/apple/device/mod.rs @@ -50,7 +50,7 @@ impl Reportable for RunError { Self::ExportFailed(err) => err.report(), Self::IpaMissing { old, new } => Report::error( "IPA appears to be missing", - format!("Not found at either {:?} or {:?}", old, new), + format!("Not found at either {old:?} or {new:?}"), ), Self::UnzipFailed(err) => Report::error("Failed to unzip archive", err), Self::DeployFailed(err) => Report::error("Failed to deploy app", err), diff --git a/src/apple/mod.rs b/src/apple/mod.rs index 240f3a7..b458a4b 100644 --- a/src/apple/mod.rs +++ b/src/apple/mod.rs @@ -27,7 +27,7 @@ pub struct AuthCredentials { pub fn rust_version_check(wrapper: &TextWrapper) -> Result<(), util::RustVersionError> { util::RustVersion::check().map(|version| if !version.valid() { Report::action_request( - format!("iOS linking is broken on Rust versions later than 1.45.2 (d3fb005a3 2020-07-31) and earlier than 1.49.0-nightly (ffa2e7ae8 2020-10-24), but you're on {}!", version), + format!("iOS linking is broken on Rust versions later than 1.45.2 (d3fb005a3 2020-07-31) and earlier than 1.49.0-nightly (ffa2e7ae8 2020-10-24), but you're on {version}!"), "This is fixed in Rust 1.49.0 and later:\n`rustup update stable && rustup default stable`", ).print(wrapper); }) diff --git a/src/apple/project.rs b/src/apple/project.rs index c52e070..00ef145 100644 --- a/src/apple/project.rs +++ b/src/apple/project.rs @@ -50,7 +50,7 @@ impl Reportable for Error { Report::error("Asset dir couldn't be symlinked into Xcode project", err) } Self::DirectoryCreationFailed { path, cause } => Report::error( - format!("Failed to create iOS assets directory at {:?}", path), + format!("Failed to create iOS assets directory at {path:?}"), cause, ), Self::XcodegenFailed(err) => Report::error("Failed to run `xcodegen`", err), diff --git a/src/bicycle/mod.rs b/src/bicycle/mod.rs index 44ad6d4..9a02c08 100644 --- a/src/bicycle/mod.rs +++ b/src/bicycle/mod.rs @@ -351,7 +351,7 @@ impl Bicycle { if let Prefix::Disk(_) = prefix.kind() { return p .to_str() - .map(|s| format!("\\\\?\\{}", s)) + .map(|s| format!("\\\\?\\{s}")) .map(PathBuf::from) .unwrap_or_else(|| p); } diff --git a/src/bin/cargo-mobile.rs b/src/bin/cargo-mobile.rs index c5d9202..da57223 100644 --- a/src/bin/cargo-mobile.rs +++ b/src/bin/cargo-mobile.rs @@ -119,10 +119,10 @@ impl Reportable for Error { match self { Self::InitFailed(err) => err.report(), Self::DirCreationFailed { path, source } => { - Report::error(format!("Failed to create directory {:?}", path), source) + Report::error(format!("Failed to create directory {path:?}"), source) } Self::DirChangeFailed { path, source } => Report::error( - format!("Failed to change current directory {:?}", path), + format!("Failed to change current directory {path:?}"), source, ), Self::OpenFailed(err) => { diff --git a/src/config/app/identifier.rs b/src/config/app/identifier.rs index b11fbeb..b9913b6 100644 --- a/src/config/app/identifier.rs +++ b/src/config/app/identifier.rs @@ -83,24 +83,21 @@ impl fmt::Display for IdentifierError { list_display( &bad_chars .iter() - .map(|c| format!("'{}'", c)) + .map(|c| format!("'{c}'")) .collect::>() ), ), Self::ReservedPackageName { package_name } => write!( f, - "\"{}\" is a reserved package name in this project and can't be used as a top-level identifier.", - package_name + "\"{package_name}\" is a reserved package name in this project and can't be used as a top-level identifier." ), Self::ReservedKeyword { keyword } => write!( f, - "\"{}\" is a reserved keyword in java/kotlin and can't be used. For more info, please visit https://kotlinlang.org/docs/reference/keyword-reference.html and https://docs.oracle.com/javase/tutorial/java/nutsandbolts/_keywords.html", - keyword + "\"{keyword}\" is a reserved keyword in java/kotlin and can't be used. For more info, please visit https://kotlinlang.org/docs/reference/keyword-reference.html and https://docs.oracle.com/javase/tutorial/java/nutsandbolts/_keywords.html" ), Self::StartsWithDigit { label } => write!( f, - "\"{}\" label starts with a digit, which is not allowed in java/kotlin packages.", - label + "\"{label}\" label starts with a digit, which is not allowed in java/kotlin packages." ), Self::StartsOrEndsWithADot => write!(f, "Identifier can't start or end with a dot."), Self::EmptyLabel => write!(f, "Labels can't be empty."), diff --git a/src/config/app/lib_name.rs b/src/config/app/lib_name.rs index 8726bfa..e41d9bb 100644 --- a/src/config/app/lib_name.rs +++ b/src/config/app/lib_name.rs @@ -41,36 +41,32 @@ impl Display for Invalid { Self::Empty => write!(f, "The app name can't be empty.")?, Self::NotAscii { app_name, .. } => write!( f, - "\"{}\" isn't valid ASCII.", - app_name, + "\"{app_name}\" isn't valid ASCII.", )?, - Self::StartsWithDigit { app_name, .. } => write!(f, "\"{}\" starts with a digit.", app_name)?, + Self::StartsWithDigit { app_name, .. } => write!(f, "\"{app_name}\" starts with a digit.")?, Self::ReservedKeyword { app_name } => write!( f, - "\"{}\" is a reserved keyword: https://doc.rust-lang.org/reference/keywords.html", - app_name, + "\"{app_name}\" is a reserved keyword: https://doc.rust-lang.org/reference/keywords.html", )?, Self::ReservedWindows { app_name } => write!( f, - "\"{}\" is a reserved name on Windows.", - app_name, + "\"{app_name}\" is a reserved name on Windows.", )?, Self::ReservedArtifacts { app_name } => write!( f, - "\"{}\" is reserved by Cargo.", - app_name, + "\"{app_name}\" is reserved by Cargo.", )?, Self::NotAlphanumericOrUnderscore { app_name, naughty_chars, .. } => write!( f, "\"{}\" contains {}, but only lowercase letters, numbers, and underscores are allowed.", app_name, util::list_display( - &naughty_chars.iter().map(|c| format!("'{}'", c)).collect::>() + &naughty_chars.iter().map(|c| format!("'{c}'")).collect::>() ), )?, } if let Some(suggested) = self.suggested() { - write!(f, " \"{}\" would work, if you'd like!", suggested)?; + write!(f, " \"{suggested}\" would work, if you'd like!")?; } Ok(()) } @@ -139,7 +135,7 @@ fn transliterate_initial_number(s: &str) -> String { ..english_numbers::Formatting::none() }, ); - normalize_case(&format!("{}-{}", transliterated, tail)) + normalize_case(&format!("{transliterated}-{tail}")) } fn char_allowed(c: char) -> bool { diff --git a/src/config/app/mod.rs b/src/config/app/mod.rs index 18d1186..c5e37c9 100644 --- a/src/config/app/mod.rs +++ b/src/config/app/mod.rs @@ -219,7 +219,7 @@ impl App { .split('.') .map(|s| { if crate::reserved_names::KOTLIN_ONLY_KEYWORDS.contains(&s) { - format!("`{}`", s) + format!("`{s}`") } else { s.to_string() } diff --git a/src/config/app/name.rs b/src/config/app/name.rs index ea52276..2e51896 100644 --- a/src/config/app/name.rs +++ b/src/config/app/name.rs @@ -41,36 +41,32 @@ impl Display for Invalid { Self::Empty => write!(f, "The app name can't be empty.")?, Self::NotAscii { app_name, .. } => write!( f, - "\"{}\" isn't valid ASCII.", - app_name, + "\"{app_name}\" isn't valid ASCII.", )?, - Self::StartsWithDigit { app_name, .. } => write!(f, "\"{}\" starts with a digit.", app_name)?, + Self::StartsWithDigit { app_name, .. } => write!(f, "\"{app_name}\" starts with a digit.")?, Self::ReservedKeyword { app_name } => write!( f, - "\"{}\" is a reserved keyword: https://doc.rust-lang.org/reference/keywords.html", - app_name, + "\"{app_name}\" is a reserved keyword: https://doc.rust-lang.org/reference/keywords.html", )?, Self::ReservedWindows { app_name } => write!( f, - "\"{}\" is a reserved name on Windows.", - app_name, + "\"{app_name}\" is a reserved name on Windows.", )?, Self::ReservedArtifacts { app_name } => write!( f, - "\"{}\" is reserved by Cargo.", - app_name, + "\"{app_name}\" is reserved by Cargo.", )?, Self::NotAlphanumericHyphenOrUnderscore { app_name, naughty_chars, .. } => write!( f, "\"{}\" contains {}, but only lowercase letters, numbers, hyphens, and underscores are allowed.", app_name, util::list_display( - &naughty_chars.iter().map(|c| format!("'{}'", c)).collect::>() + &naughty_chars.iter().map(|c| format!("'{c}'")).collect::>() ), )?, } if let Some(suggested) = self.suggested() { - write!(f, " \"{}\" would work, if you'd like!", suggested)?; + write!(f, " \"{suggested}\" would work, if you'd like!")?; } Ok(()) } @@ -139,7 +135,7 @@ fn transliterate_initial_number(s: &str) -> String { ..english_numbers::Formatting::none() }, ); - normalize_case(&format!("{}-{}", transliterated, tail)) + normalize_case(&format!("{transliterated}-{tail}")) } fn char_allowed(c: char) -> bool { diff --git a/src/config/app/raw.rs b/src/config/app/raw.rs index ad53901..bf169e7 100644 --- a/src/config/app/raw.rs +++ b/src/config/app/raw.rs @@ -62,15 +62,14 @@ impl Display for DefaultsError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { Self::CurrentDirFailed(err) => { - write!(f, "Failed to get current working directory: {}", err) + write!(f, "Failed to get current working directory: {err}") } Self::CurrentDirHasNoName(cwd) => { - write!(f, "Current working directory has no name: {:?}", cwd) + write!(f, "Current working directory has no name: {cwd:?}") } Self::CurrentDirInvalidUtf8(cwd) => write!( f, - "Current working directory contained invalid UTF-8: {:?}", - cwd + "Current working directory contained invalid UTF-8: {cwd:?}" ), } } @@ -118,7 +117,7 @@ pub enum DetectError { impl Display for DetectError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - Self::DefaultsFailed(err) => write!(f, "Failed to detect default values: {}", err), + Self::DefaultsFailed(err) => write!(f, "Failed to detect default values: {err}"), Self::NameNotDetected => write!(f, "No app name was detected."), } } @@ -137,17 +136,17 @@ pub enum PromptError { impl Display for PromptError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - Self::DefaultsFailed(err) => write!(f, "Failed to detect default values: {}", err), - Self::NamePromptFailed(err) => write!(f, "Failed to prompt for name: {}", err), + Self::DefaultsFailed(err) => write!(f, "Failed to detect default values: {err}"), + Self::NamePromptFailed(err) => write!(f, "Failed to prompt for name: {err}"), Self::StylizedNamePromptFailed(err) => { - write!(f, "Failed to prompt for stylized name: {}", err) + write!(f, "Failed to prompt for stylized name: {err}") } Self::IdentifierPromptFailed(err) => { - write!(f, "Failed to prompt for identifier: {}", err) + write!(f, "Failed to prompt for identifier: {err}") } - Self::ListTemplatePacksFailed(err) => write!(f, "{}", err), + Self::ListTemplatePacksFailed(err) => write!(f, "{err}"), Self::TemplatePackPromptFailed(err) => { - write!(f, "Failed to prompt for template pack: {}", err) + write!(f, "Failed to prompt for template pack: {err}") } } } @@ -227,7 +226,7 @@ impl Raw { Err(err) => { println!( "{}", - wrapper.fill(&format!("Sorry! {}", err)).bright_magenta() + wrapper.fill(&format!("Sorry! {err}")).bright_magenta() ) } } diff --git a/src/device.rs b/src/device.rs index 3ddaa0d..f4d6764 100644 --- a/src/device.rs +++ b/src/device.rs @@ -24,7 +24,7 @@ pub struct PromptError { impl Display for PromptError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match &self.cause { - PromptErrorCause::DetectionFailed(err) => write!(f, "{}", err), + PromptErrorCause::DetectionFailed(err) => write!(f, "{err}"), PromptErrorCause::PromptFailed(err) => { write!(f, "Failed to prompt for {} device: {}", self.name, err) } diff --git a/src/doctor/section/android.rs b/src/doctor/section/android.rs index 9605c03..32aff89 100644 --- a/src/doctor/section/android.rs +++ b/src/doctor/section/android.rs @@ -13,7 +13,7 @@ pub fn check(env: &Env) -> Result { sdk_version, util::contract_home(android_env.android_home())?, )), - Err(err) => Err(format!("Failed to get SDK version: {}", err)), + Err(err) => Err(format!("Failed to get SDK version: {err}")), }) .with_item(match android_env.ndk.version() { Ok(ndk_version) => Ok(format!( @@ -21,7 +21,7 @@ pub fn check(env: &Env) -> Result { ndk_version, util::contract_home(android_env.ndk.home())?, )), - Err(err) => Err(format!("Failed to get NDK version: {}", err)), + Err(err) => Err(format!("Failed to get NDK version: {err}")), }), Err(err) => section.with_failure(err), }) diff --git a/src/doctor/section/apple.rs b/src/doctor/section/apple.rs index 1268c1f..aff3105 100644 --- a/src/doctor/section/apple.rs +++ b/src/doctor/section/apple.rs @@ -10,24 +10,20 @@ fn validate_developer_dir() -> Result { static FORBIDDEN: &str = "/Library/Developer/CommandLineTools"; static SUGGESTED: &str = "/Applications/Xcode.app/Contents/Developer"; let xcode_developer_dir = xcode_plugin::xcode_developer_dir() - .map_err(|err| format!("Failed to get active Xcode developer dir: {}", err))?; + .map_err(|err| format!("Failed to get active Xcode developer dir: {err}"))?; let xcode_developer_dir = { if xcode_developer_dir == Path::new(FORBIDDEN) { println!( - "Your active toolchain appears to be the Apple command-line tools: {:?}", - xcode_developer_dir + "Your active toolchain appears to be the Apple command-line tools: {xcode_developer_dir:?}" ); println!("Changing your active toolchain to Xcode may be necessary for everything to work correctly."); let answer = loop { if let Some(answer) = prompt::yes_no( - format!("Would you like us to change it to {:?} for you?", SUGGESTED), + format!("Would you like us to change it to {SUGGESTED:?} for you?"), Some(true), ) .map_err(|err| { - format!( - "Failed to prompt for changing the Xcode developer dir: {}", - err - ) + format!("Failed to prompt for changing the Xcode developer dir: {err}") })? { break answer; } @@ -36,7 +32,7 @@ fn validate_developer_dir() -> Result { duct::cmd("xcode-select", ["-s", SUGGESTED]) .dup_stdio() .run() - .map_err(|err| format!("Failed to update Xcode developer dir: {}", err))?; + .map_err(|err| format!("Failed to update Xcode developer dir: {err}"))?; Path::new(SUGGESTED) } else { &xcode_developer_dir @@ -45,7 +41,7 @@ fn validate_developer_dir() -> Result { &xcode_developer_dir } }; - Ok(format!("Active developer dir: {:?}", xcode_developer_dir)) + Ok(format!("Active developer dir: {xcode_developer_dir:?}")) } fn validate_xcode_plugin(xcode_version: (u32, u32), section: Section) -> Section { @@ -73,8 +69,7 @@ fn validate_xcode_plugin(xcode_version: (u32, u32), section: Section) -> Section Item::warning("xcode-rust-plugin is outdated") }), Err(err) => section.with_failure(format!( - "Failed to check xcode-rust-plugin installation status: {}", - err + "Failed to check xcode-rust-plugin installation status: {err}" )), } .with_item(match ctx.check_uuid() { @@ -92,13 +87,10 @@ fn validate_xcode_plugin(xcode_version: (u32, u32), section: Section) -> Section } } Err(err) => Item::failure(format!( - "Failed to check xcode-rust-plugin UUID status: {}", - err + "Failed to check xcode-rust-plugin UUID status: {err}" )), }), - Err(err) => { - section.with_failure(format!("Failed to get xcode-rust-plugin context: {}", err)) - } + Err(err) => section.with_failure(format!("Failed to get xcode-rust-plugin context: {err}")), } } @@ -108,8 +100,8 @@ pub fn check() -> Section { .with_item( xcode_version .as_ref() - .map(|(major, minor)| format!("Xcode v{}.{}", major, minor)) - .map_err(|err| format!("Failed to check Xcode version: {}", err)), + .map(|(major, minor)| format!("Xcode v{major}.{minor}")) + .map_err(|err| format!("Failed to check Xcode version: {err}")), ) .with_item(validate_developer_dir()) .with_item( @@ -117,14 +109,14 @@ pub fn check() -> Section { .stderr_capture() .read() .map(|version| format!("ios-deploy v{}", version.trim())) - .map_err(|err| format!("Failed to check ios-deploy version: {}", err)), + .map_err(|err| format!("Failed to check ios-deploy version: {err}")), ) .with_item( duct::cmd("xcodegen", ["--version"]) .stderr_capture() .read() .map(|version| version.trim().replace("Version: ", "XcodeGen v")) - .map_err(|err| format!("Failed to check ios-deploy version: {}", err)), + .map_err(|err| format!("Failed to check ios-deploy version: {err}")), ); let section = if let Ok(version) = xcode_version { validate_xcode_plugin(version, section) @@ -139,6 +131,6 @@ pub fn check() -> Section { format!("Development team: {} ({})", team.name, team.id) })) } - Err(err) => section.with_failure(format!("Failed to find development teams: {}", err)), + Err(err) => section.with_failure(format!("Failed to find development teams: {err}")), } } diff --git a/src/doctor/section/cargo_mobile.rs b/src/doctor/section/cargo_mobile.rs index a5dac80..7ec8ced 100644 --- a/src/doctor/section/cargo_mobile.rs +++ b/src/doctor/section/cargo_mobile.rs @@ -8,7 +8,7 @@ use crate::{ fn check_os() -> Result { os::Info::check() .map(|info| format!("{} v{}", info.name, info.version)) - .map_err(|err| format!("Failed to get OS info: {}", err)) + .map_err(|err| format!("Failed to get OS info: {err}")) } fn check_rust() -> Result { @@ -17,18 +17,17 @@ fn check_rust() -> Result { .and_then(|version| { version .valid() - .then(|| format!("rustc v{}", version)) + .then(|| format!("rustc v{version}")) .ok_or_else(|| { format!( - "iOS linking is broken on rustc v{}; please update to 1.49.0 or later", - version + "iOS linking is broken on rustc v{version}; please update to 1.49.0 or later" ) }) }) } pub fn check() -> Result { - let section = Section::new(format!("cargo-mobile {}", VERSION_SHORT)); + let section = Section::new(format!("cargo-mobile {VERSION_SHORT}")); Ok(match util::install_dir() { Ok(install_dir) => section .with_item(util::installed_commit_msg().map(|msg| { @@ -42,8 +41,7 @@ pub fn check() -> Result { )) } else { Err(format!( - "The cargo-mobile2 installation directory is missing! Checked at {:?}", - install_dir, + "The cargo-mobile2 installation directory is missing! Checked at {install_dir:?}", )) }), Err(err) => section.with_failure(err), diff --git a/src/doctor/section/device_list.rs b/src/doctor/section/device_list.rs index cc22866..508aea3 100644 --- a/src/doctor/section/device_list.rs +++ b/src/doctor/section/device_list.rs @@ -11,14 +11,14 @@ pub fn check(env: &Env) -> Section { let section = { match crate::apple::device::list_devices(env) { Ok(list) => section.with_victories(list), - Err(err) => section.with_failure(format!("Failed to get iOS device list: {}", err)), + Err(err) => section.with_failure(format!("Failed to get iOS device list: {err}")), } }; let section = if let Ok(android_env) = android::env::Env::from_env(env.clone()) { match adb::device_list(&android_env) { Ok(list) => section.with_victories(list), - Err(err) => section.with_failure(format!("Failed to get Android device list: {}", err)), + Err(err) => section.with_failure(format!("Failed to get Android device list: {err}")), } } else { section diff --git a/src/init.rs b/src/init.rs index c9d7dae..65d7780 100644 --- a/src/init.rs +++ b/src/init.rs @@ -71,10 +71,10 @@ impl Reportable for Error { fn report(&self) -> Report { match self { Self::ConfigLoadOrGenFailed(err) => err.report(), - Self::DotFirstInitWriteFailed { path, cause } => Report::error(format!("Failed to write first init dot file {:?}", path), cause), + Self::DotFirstInitWriteFailed { path, cause } => Report::error(format!("Failed to write first init dot file {path:?}"), cause), Self::FilterConfigureFailed(err) => Report::error("Failed to configure template filter", err), Self::ProjectInitFailed(err) => err.report(), - Self::AssetDirCreationFailed { asset_dir, cause } => Report::error(format!("Failed to create asset dir {:?}", asset_dir), cause), + Self::AssetDirCreationFailed { asset_dir, cause } => Report::error(format!("Failed to create asset dir {asset_dir:?}"), cause), Self::CodeCommandPresentFailed(err) => Report::error("Failed to check for presence of `code` command", err), Self::LldbExtensionInstallFailed(err) => Report::error("Failed to install CodeLLDB extension", err), Self::DotCargoLoadFailed(err) => err.report(), @@ -85,7 +85,7 @@ impl Reportable for Error { #[cfg(target_os = "macos")] Self::AppleInitFailed(err) => err.report(), Self::DotCargoWriteFailed(err) => err.report(), - Self::DotFirstInitDeleteFailed { path, cause } => Report::action_request(format!("Failed to delete first init dot file {:?}; the project generated successfully, but `cargo mobile init` will have unexpected results unless you manually delete this file!", path), cause), + Self::DotFirstInitDeleteFailed { path, cause } => Report::action_request(format!("Failed to delete first init dot file {path:?}; the project generated successfully, but `cargo mobile init` will have unexpected results unless you manually delete this file!"), cause), Self::OpenInEditorFailed(err) => Report::error("Failed to open project in editor (your project generated successfully though, so no worries!)", err), } } diff --git a/src/project.rs b/src/project.rs index e3390db..91519b5 100644 --- a/src/project.rs +++ b/src/project.rs @@ -27,8 +27,7 @@ impl Reportable for Error { Self::TemplatePackResolve(err) => Report::error("Failed to resolve template pack", err), Self::Processing { src, dest, cause } => Report::error( format!( - "Base project template processing from src {:?} to dest {:?} failed", - src, dest, + "Base project template processing from src {src:?} to dest {dest:?} failed", ), cause, ), diff --git a/src/templating/filter.rs b/src/templating/filter.rs index f9dab28..718c782 100644 --- a/src/templating/filter.rs +++ b/src/templating/filter.rs @@ -19,8 +19,7 @@ impl Display for FilterError { match self { Self::ReadDirFailed { path, cause } => write!( f, - "App root directory {:?} couldn't be checked for emptiness: {}", - path, cause + "App root directory {path:?} couldn't be checked for emptiness: {cause}" ), } } diff --git a/src/templating/init.rs b/src/templating/init.rs index d139ee9..b0cad34 100644 --- a/src/templating/init.rs +++ b/src/templating/init.rs @@ -60,7 +60,7 @@ fn quote_and_join( out: &mut dyn Output, ) -> HelperResult { out.write( - &get_str_array(helper, |s| format!("{:?}", s)) + &get_str_array(helper, |s| format!("{s:?}")) .ok_or_else(|| { RenderErrorReason::Other("`quote-and-join` helper wasn't given an array".into()) })? @@ -134,7 +134,7 @@ fn escape_kotlin_keyword( .split('.') .map(|s| { if KOTLIN_ONLY_KEYWORDS.contains(&s) { - format!("`{}`", s) + format!("`{s}`") } else { s.to_string() } diff --git a/src/templating/mod.rs b/src/templating/mod.rs index 2137156..73cc1c8 100644 --- a/src/templating/mod.rs +++ b/src/templating/mod.rs @@ -62,7 +62,7 @@ impl Pack { let path = { let dir = dir.as_ref(); let name = name.as_ref(); - let toml_path = dir.join(format!("{}.toml", name)); + let toml_path = dir.join(format!("{name}.toml")); let path = dir.join(name); check_path(name, &toml_path) .or_else(|| check_path(name, &path)) @@ -137,12 +137,12 @@ pub enum ListError { impl Display for ListError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - Self::NoHomeDir(err) => write!(f, "{}", err), + Self::NoHomeDir(err) => write!(f, "{err}"), Self::DirReadFailed { dir, cause } => { - write!(f, "Failed to read directory {:?}: {}", dir, cause) + write!(f, "Failed to read directory {dir:?}: {cause}") } Self::DirEntryReadFailed { dir, cause } => { - write!(f, "Failed to read entry in directory {:?}: {}", dir, cause) + write!(f, "Failed to read entry in directory {dir:?}: {cause}") } } } diff --git a/src/update.rs b/src/update.rs index 31fa710..724b985 100644 --- a/src/update.rs +++ b/src/update.rs @@ -32,21 +32,19 @@ pub enum Error { impl Display for Error { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - Self::NoHomeDir(err) => write!(f, "{}", err), + Self::NoHomeDir(err) => write!(f, "{err}"), Self::StatusFailed(err) => { - write!(f, "Failed to check status of `cargo-mobile2` repo: {}", err) + write!(f, "Failed to check status of `cargo-mobile2` repo: {err}") } Self::MarkerCreateFailed { path, cause } => { - write!(f, "Failed to create marker file at {:?}: {}", path, cause) + write!(f, "Failed to create marker file at {path:?}: {cause}") + } + Self::UpdateFailed(err) => write!(f, "Failed to update `cargo-mobile2` repo: {err}"), + Self::InstallFailed(err) => { + write!(f, "Failed to install new version of `cargo-mobile2`: {err}") } - Self::UpdateFailed(err) => write!(f, "Failed to update `cargo-mobile2` repo: {}", err), - Self::InstallFailed(err) => write!( - f, - "Failed to install new version of `cargo-mobile2`: {}", - err - ), Self::MarkerDeleteFailed { path, cause } => { - write!(f, "Failed to delete marker file at {:?}: {}", path, cause) + write!(f, "Failed to delete marker file at {path:?}: {cause}") } } } @@ -105,7 +103,7 @@ pub fn update(wrapper: &TextWrapper) -> Result<(), Error> { let details = util::unwrap_either( repo.latest_subject() .map(util::format_commit_msg) - .map_err(|err| format!("But we failed to get the latest commit message: {}", err)), + .map_err(|err| format!("But we failed to get the latest commit message: {err}")), ); Report::victory(msg, details).print(wrapper); Ok(()) diff --git a/src/util/cli.rs b/src/util/cli.rs index 185ecf5..22bd3cd 100644 --- a/src/util/cli.rs +++ b/src/util/cli.rs @@ -75,8 +75,8 @@ impl Report { pub fn new(label: Label, msg: impl Display, details: impl Display) -> Self { Self { label, - msg: format!("{}", msg), - details: format!("{}", details), + msg: format!("{msg}"), + details: format!("{details}"), } } @@ -122,9 +122,9 @@ impl Report { pub fn print(&self, wrapper: &TextWrapper) { let s = self.format(wrapper); if matches!(self.label, Label::Error) { - eprint!("{}", s) + eprint!("{s}") } else { - print!("{}", s) + print!("{s}") } } } @@ -158,7 +158,7 @@ mod interface { pub static SETTINGS: &[AppSettings] = &[AppSettings::SubcommandRequiredElseHelp]; pub fn bin_name(name: &str) -> String { - format!("cargo {}", name) + format!("cargo {name}") } pub static VERSION_LONG: Lazy = Lazy::new(|| match util::installed_commit_msg() { diff --git a/src/util/git/repo.rs b/src/util/git/repo.rs index 26e3504..f62bcfa 100644 --- a/src/util/git/repo.rs +++ b/src/util/git/repo.rs @@ -22,19 +22,19 @@ pub enum Error { impl Display for Error { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - Self::NoHomeDir(err) => write!(f, "{}", err), - Self::FetchFailed(err) => write!(f, "Failed to fetch repo: {}", err), - Self::RevParseLocalFailed(err) => write!(f, "Failed to get checkout revision: {}", err), + Self::NoHomeDir(err) => write!(f, "{err}"), + Self::FetchFailed(err) => write!(f, "Failed to fetch repo: {err}"), + Self::RevParseLocalFailed(err) => write!(f, "Failed to get checkout revision: {err}"), Self::RevParseRemoteFailed(err) => { - write!(f, "Failed to get upstream revision: {}", err) + write!(f, "Failed to get upstream revision: {err}") } - Self::LogFailed(err) => write!(f, "Failed to get commit log: {}", err), + Self::LogFailed(err) => write!(f, "Failed to get commit log: {err}"), Self::ParentDirCreationFailed { path, cause } => { - write!(f, "Failed to create parent directory {:?}: {}", path, cause) + write!(f, "Failed to create parent directory {path:?}: {cause}") } - Self::CloneFailed(err) => write!(f, "Failed to clone repo: {}", err), - Self::ResetFailed(err) => write!(f, "Failed to reset repo: {}", err), - Self::CleanFailed(err) => write!(f, "Failed to clean repo: {}", err), + Self::CloneFailed(err) => write!(f, "Failed to clone repo: {err}"), + Self::ResetFailed(err) => write!(f, "Failed to reset repo: {err}"), + Self::CleanFailed(err) => write!(f, "Failed to clean repo: {err}"), } } } diff --git a/src/util/git/submodule.rs b/src/util/git/submodule.rs index 71508ad..dfe716f 100644 --- a/src/util/git/submodule.rs +++ b/src/util/git/submodule.rs @@ -113,7 +113,7 @@ impl Submodule { fn in_index(&self, git: Git<'_>, name: &str) -> io::Result { git.modules().map(|modules| { modules - .filter(|modules| modules.contains(&format!("[submodule {:?}]", name))) + .filter(|modules| modules.contains(&format!("[submodule {name:?}]"))) .is_some() }) } @@ -121,7 +121,7 @@ impl Submodule { fn initialized(&self, git: Git<'_>, name: &str) -> io::Result { git.config().map(|config| { config - .filter(|config| config.contains(&format!("[submodule {:?}]", name))) + .filter(|config| config.contains(&format!("[submodule {name:?}]"))) .is_some() }) } diff --git a/src/util/ln.rs b/src/util/ln.rs index 1413347..3fecf1e 100644 --- a/src/util/ln.rs +++ b/src/util/ln.rs @@ -68,8 +68,8 @@ impl Display for ErrorCause { Self::MissingFileName => { write!(f, "Neither the source nor target contained a file name.",) } - Self::CommandFailed(err) => write!(f, "`ln` command failed: {}", err), - Self::IOError(err) => write!(f, "IO error: {}", err), + Self::CommandFailed(err) => write!(f, "`ln` command failed: {err}"), + Self::IOError(err) => write!(f, "IO error: {err}"), Self::SymlinkNotAllowed => { write!( f, diff --git a/src/util/mod.rs b/src/util/mod.rs index 4d856de..0565247 100644 --- a/src/util/mod.rs +++ b/src/util/mod.rs @@ -37,9 +37,9 @@ pub fn list_display(list: &[impl Display]) -> String { for (idx, item) in list.iter().enumerate() { let formatted = if idx + 1 == list.len() { // this is the last item - format!("and {}", item) + format!("and {item}") } else { - format!("{}, ", item) + format!("{item}, ") }; display.push_str(&formatted); } @@ -385,7 +385,7 @@ impl Display for RustVersion { if let Some(flavor) = &self.flavor { write!(f, "-{}", flavor.flavor)?; if let Some(candidate) = &flavor.candidate { - write!(f, ".{}", candidate)?; + write!(f, ".{candidate}")?; } } if let Some(details) = &self.details { @@ -465,7 +465,7 @@ impl RustVersion { } pub fn prepend_to_path(path: impl Display, base_path: impl Display) -> String { - format!("{}:{}", path, base_path) + format!("{path}:{base_path}") } pub fn command_present(name: &str) -> Result { @@ -483,11 +483,11 @@ pub enum PipeError { impl Display for PipeError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - Self::TxCommandFailed(err) => write!(f, "Failed to run sending command: {}", err), - Self::RxCommandFailed(err) => write!(f, "Failed to run receiving command: {}", err), - Self::PipeFailed(err) => write!(f, "Failed to pipe output: {}", err), + Self::TxCommandFailed(err) => write!(f, "Failed to run sending command: {err}"), + Self::RxCommandFailed(err) => write!(f, "Failed to run receiving command: {err}"), + Self::PipeFailed(err) => write!(f, "Failed to pipe output: {err}"), Self::WaitFailed(err) => { - write!(f, "Failed to wait for receiving command to exit: {}", err) + write!(f, "Failed to wait for receiving command to exit: {err}") } } } @@ -577,7 +577,7 @@ pub fn installed_commit_msg() -> Result, InstalledCommitMsgError> } pub fn format_commit_msg(msg: String) -> String { - format!("Contains commits up to {:?}", msg) + format!("Contains commits up to {msg:?}") } pub fn unwrap_either(result: Result) -> T { @@ -650,8 +650,8 @@ impl Serialize for OneOrMany { S: Serializer, { let serialized_str = match self { - Self::One(one) => format!("{:?}", one), - Self::Many(vec) => format!("{:?}", vec), + Self::One(one) => format!("{one:?}"), + Self::Many(vec) => format!("{vec:?}"), }; serializer.serialize_str(&serialized_str) } diff --git a/src/util/path.rs b/src/util/path.rs index e702057..bc219b6 100644 --- a/src/util/path.rs +++ b/src/util/path.rs @@ -178,16 +178,12 @@ pub enum NormalizationError { impl Display for NormalizationError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - Self::CanonicalizationFailed { path, cause } => write!( - f, - "Failed to canonicalize existing path {:?}: {}", - path, cause - ), - Self::PathAbsFailed { path, cause } => write!( - f, - "Failed to normalize non-existent path {:?}: {}", - path, cause - ), + Self::CanonicalizationFailed { path, cause } => { + write!(f, "Failed to canonicalize existing path {path:?}: {cause}") + } + Self::PathAbsFailed { path, cause } => { + write!(f, "Failed to normalize non-existent path {path:?}: {cause}") + } } } } diff --git a/src/util/prompt.rs b/src/util/prompt.rs index 782614f..9bcb96a 100644 --- a/src/util/prompt.rs +++ b/src/util/prompt.rs @@ -6,7 +6,7 @@ use std::{ pub fn minimal(msg: impl Display) -> io::Result { let mut input = String::new(); - print!("{}: ", msg); + print!("{msg}: "); io::stdout().flush()?; io::stdin().read_line(&mut input)?; @@ -22,7 +22,7 @@ pub fn default( let msg = if let Some(default_color) = default_color { format!("{} ({})", msg, default.color(default_color).bold()) } else { - format!("{} ({})", msg, default) + format!("{msg} ({default})") }; minimal(msg) } else { @@ -44,7 +44,7 @@ pub fn yes_no(msg: impl Display, default: Option) -> io::Result "[y/N]", None => "[y/n]", }; - minimal(format!("{} {}", msg, y_n)).map(|response| { + minimal(format!("{msg} {y_n}")).map(|response| { if response.eq_ignore_ascii_case("y") { Some(true) } else if response.eq_ignore_ascii_case("n") { @@ -75,7 +75,7 @@ pub fn list( alternative: Option<&str>, msg: impl Display, ) -> io::Result { - println!("{}:", header); + println!("{header}:"); let choice_count = choices.len(); list_display_only(choices, choice_count); if let Some(alternative) = alternative {