From 6b2b9d6cbf6d988471f2caaac465b6eda2b314c5 Mon Sep 17 00:00:00 2001 From: Fabian-Lars Date: Fri, 27 Jun 2025 15:33:36 +0200 Subject: [PATCH] chore: clippy 1.88 (#13720) --- bench/src/build_benchmark_jsons.rs | 4 +-- bench/src/run_benchmark.rs | 10 +++---- bench/src/utils.rs | 6 ++-- .../src/bundle/linux/appimage.rs | 3 +- .../tauri-bundler/src/bundle/linux/debian.rs | 11 ++++--- crates/tauri-bundler/src/bundle/linux/rpm.rs | 3 +- crates/tauri-bundler/src/bundle/macos/app.rs | 29 +++++++------------ .../tauri-bundler/src/bundle/macos/dmg/mod.rs | 9 +++--- crates/tauri-bundler/src/bundle/macos/ios.rs | 10 +++---- .../src/bundle/windows/msi/mod.rs | 13 ++++----- .../src/bundle/windows/nsis/mod.rs | 3 +- crates/tauri-cli/src/acl/capability/new.rs | 2 +- crates/tauri-cli/src/helpers/mod.rs | 2 +- crates/tauri-cli/src/info/env_system.rs | 2 +- .../src/migrate/migrations/v1/manifest.rs | 4 +-- .../tauri-cli/src/mobile/android/project.rs | 2 +- crates/tauri-cli/src/mobile/init.rs | 2 +- .../tauri-cli/src/mobile/ios/xcode_script.rs | 6 ++-- crates/tauri-cli/src/plugin/android.rs | 10 +++---- crates/tauri-cli/src/plugin/init.rs | 2 +- crates/tauri-cli/src/plugin/ios.rs | 7 ++--- crates/tauri-driver/src/cli.rs | 8 ++--- crates/tauri-driver/src/main.rs | 2 +- crates/tauri-driver/src/server.rs | 4 +-- crates/tauri-driver/src/webdriver.rs | 9 +++--- crates/tauri-macos-sign/src/keychain.rs | 2 +- .../tauri-macos-sign/src/keychain/identity.rs | 12 +++----- crates/tauri-macos-sign/src/lib.rs | 2 +- crates/tauri-plugin/src/build/mobile.rs | 6 ++-- crates/tauri-utils/src/acl/build.rs | 2 +- crates/tauri-utils/src/config.rs | 2 +- crates/tauri/src/protocol/isolation.rs | 2 +- examples/api/src-tauri/src/lib.rs | 4 +-- .../src-tauri/tauri-plugin-sample/src/lib.rs | 4 +-- examples/resources/src-tauri/src/main.rs | 2 +- packages/cli/src/lib.rs | 2 +- 36 files changed, 90 insertions(+), 113 deletions(-) diff --git a/bench/src/build_benchmark_jsons.rs b/bench/src/build_benchmark_jsons.rs index 71a6e32cd..1a8423aff 100644 --- a/bench/src/build_benchmark_jsons.rs +++ b/bench/src/build_benchmark_jsons.rs @@ -52,7 +52,7 @@ fn main() { .expect("Something wrong with tauri_data"), &serde_json::to_value(all_data).expect("Unable to build final json (all)"), ) - .unwrap_or_else(|_| panic!("Unable to write {:?}", tauri_data)); + .unwrap_or_else(|_| panic!("Unable to write {tauri_data:?}")); utils::write_json( tauri_recent @@ -60,5 +60,5 @@ fn main() { .expect("Something wrong with tauri_recent"), &serde_json::to_value(recent).expect("Unable to build final json (recent)"), ) - .unwrap_or_else(|_| panic!("Unable to write {:?}", tauri_recent)); + .unwrap_or_else(|_| panic!("Unable to write {tauri_recent:?}")); } diff --git a/bench/src/run_benchmark.rs b/bench/src/run_benchmark.rs index d55d8ee03..76a73b0a3 100644 --- a/bench/src/run_benchmark.rs +++ b/bench/src/run_benchmark.rs @@ -89,7 +89,7 @@ fn run_max_mem_benchmark() -> Result> { let mut results = HashMap::::new(); for (name, example_exe) in get_all_benchmarks() { - let benchmark_file = utils::target_dir().join(format!("mprof{}_.dat", name)); + let benchmark_file = utils::target_dir().join(format!("mprof{name}_.dat")); let benchmark_file = benchmark_file.to_str().unwrap(); let proc = Command::new("mprof") @@ -105,7 +105,7 @@ fn run_max_mem_benchmark() -> Result> { .spawn()?; let proc_result = proc.wait_with_output()?; - println!("{:?}", proc_result); + println!("{proc_result:?}"); results.insert( name.to_string(), utils::parse_max_mem(benchmark_file).unwrap(), @@ -126,11 +126,11 @@ fn rlib_size(target_dir: &std::path::Path, prefix: &str) -> u64 { if name.starts_with(prefix) && name.ends_with(".rlib") { let start = name.split('-').next().unwrap().to_string(); if seen.contains(&start) { - println!("skip {}", name); + println!("skip {name}"); } else { seen.insert(start); size += entry.metadata().unwrap().len(); - println!("check size {} {}", name, size); + println!("check size {name} {size}"); } } } @@ -142,7 +142,7 @@ fn get_binary_sizes(target_dir: &Path) -> Result> { let mut sizes = HashMap::::new(); let wry_size = rlib_size(target_dir, "libwry"); - println!("wry {} bytes", wry_size); + println!("wry {wry_size} bytes"); sizes.insert("wry_rlib".to_string(), wry_size); // add size for all EXEC_TIME_BENCHMARKS diff --git a/bench/src/utils.rs b/bench/src/utils.rs index 6571f5f2d..090b62ab6 100644 --- a/bench/src/utils.rs +++ b/bench/src/utils.rs @@ -96,8 +96,8 @@ pub fn run_collect(cmd: &[&str]) -> (String, String) { let stdout = String::from_utf8_lossy(&stdout).to_string(); let stderr = String::from_utf8_lossy(&stderr).to_string(); if !status.success() { - eprintln!("stdout: <<<{}>>>", stdout); - eprintln!("stderr: <<<{}>>>", stderr); + eprintln!("stdout: <<<{stdout}>>>"); + eprintln!("stderr: <<<{stderr}>>>"); panic!("Unexpected exit code: {:?}", status.code()); } (stdout, stderr) @@ -230,7 +230,7 @@ pub fn download_file(url: &str, filename: PathBuf) { // Downloading with curl this saves us from adding // a Rust HTTP client dependency. - println!("Downloading {}", url); + println!("Downloading {url}"); let status = Command::new("curl") .arg("-L") .arg("-s") diff --git a/crates/tauri-bundler/src/bundle/linux/appimage.rs b/crates/tauri-bundler/src/bundle/linux/appimage.rs index c7dfc6e03..6cda8c756 100644 --- a/crates/tauri-bundler/src/bundle/linux/appimage.rs +++ b/crates/tauri-bundler/src/bundle/linux/appimage.rs @@ -27,8 +27,7 @@ pub fn bundle_project(settings: &Settings) -> crate::Result> { Arch::Armhf => "armhf", target => { return Err(crate::Error::ArchError(format!( - "Unsupported architecture: {:?}", - target + "Unsupported architecture: {target:?}" ))); } }; diff --git a/crates/tauri-bundler/src/bundle/linux/debian.rs b/crates/tauri-bundler/src/bundle/linux/debian.rs index 59d1dd3d6..6f8bad688 100644 --- a/crates/tauri-bundler/src/bundle/linux/debian.rs +++ b/crates/tauri-bundler/src/bundle/linux/debian.rs @@ -49,8 +49,7 @@ pub fn bundle_project(settings: &Settings) -> crate::Result> { Arch::Riscv64 => "riscv64", target => { return Err(crate::Error::ArchError(format!( - "Unsupported architecture: {:?}", - target + "Unsupported architecture: {target:?}" ))); } }; @@ -164,7 +163,7 @@ fn generate_control_file( let dest_path = control_dir.join("control"); let mut file = fs_utils::create_file(&dest_path)?; let package = heck::AsKebabCase(settings.product_name()); - writeln!(file, "Package: {}", package)?; + writeln!(file, "Package: {package}")?; writeln!(file, "Version: {}", settings.version_string())?; writeln!(file, "Architecture: {arch}")?; // Installed-Size must be divided by 1024, see https://www.debian.org/doc/debian-policy/ch-controlfields.html#installed-size @@ -183,16 +182,16 @@ fn generate_control_file( writeln!(file, "Maintainer: {authors}")?; if let Some(section) = &settings.deb().section { - writeln!(file, "Section: {}", section)?; + writeln!(file, "Section: {section}")?; } if let Some(priority) = &settings.deb().priority { - writeln!(file, "Priority: {}", priority)?; + writeln!(file, "Priority: {priority}")?; } else { writeln!(file, "Priority: optional")?; } if let Some(homepage) = settings.homepage_url() { - writeln!(file, "Homepage: {}", homepage)?; + writeln!(file, "Homepage: {homepage}")?; } let dependencies = settings.deb().depends.as_ref().cloned().unwrap_or_default(); diff --git a/crates/tauri-bundler/src/bundle/linux/rpm.rs b/crates/tauri-bundler/src/bundle/linux/rpm.rs index e7cc8b7ef..ef49685f1 100644 --- a/crates/tauri-bundler/src/bundle/linux/rpm.rs +++ b/crates/tauri-bundler/src/bundle/linux/rpm.rs @@ -32,8 +32,7 @@ pub fn bundle_project(settings: &Settings) -> crate::Result> { Arch::Riscv64 => "riscv64", target => { return Err(crate::Error::ArchError(format!( - "Unsupported architecture: {:?}", - target + "Unsupported architecture: {target:?}" ))); } }; diff --git a/crates/tauri-bundler/src/bundle/macos/app.rs b/crates/tauri-bundler/src/bundle/macos/app.rs index fa4bd49eb..00a8596bf 100644 --- a/crates/tauri-bundler/src/bundle/macos/app.rs +++ b/crates/tauri-bundler/src/bundle/macos/app.rs @@ -65,15 +65,11 @@ pub fn bundle_project(settings: &Settings) -> crate::Result> { if app_bundle_path.exists() { fs::remove_dir_all(&app_bundle_path) - .with_context(|| format!("Failed to remove old {}", app_product_name))?; + .with_context(|| format!("Failed to remove old {app_product_name}"))?; } let bundle_directory = app_bundle_path.join("Contents"); - fs::create_dir_all(&bundle_directory).with_context(|| { - format!( - "Failed to create bundle directory at {:?}", - bundle_directory - ) - })?; + fs::create_dir_all(&bundle_directory) + .with_context(|| format!("Failed to create bundle directory at {bundle_directory:?}"))?; let resources_dir = bundle_directory.join("Resources"); let bin_dir = bundle_directory.join("MacOS"); @@ -160,7 +156,7 @@ fn copy_binaries_to_bundle( let bin_path = settings.binary_path(bin); let dest_path = dest_dir.join(bin.name()); fs_utils::copy_file(&bin_path, &dest_path) - .with_context(|| format!("Failed to copy binary from {:?}", bin_path))?; + .with_context(|| format!("Failed to copy binary from {bin_path:?}"))?; paths.push(dest_path); } Ok(paths) @@ -176,10 +172,10 @@ fn copy_custom_files_to_bundle(bundle_directory: &Path, settings: &Settings) -> }; if path.is_file() { fs_utils::copy_file(path, &bundle_directory.join(contents_path)) - .with_context(|| format!("Failed to copy file {:?} to {:?}", path, contents_path))?; + .with_context(|| format!("Failed to copy file {path:?} to {contents_path:?}"))?; } else { fs_utils::copy_dir(path, &bundle_directory.join(contents_path)) - .with_context(|| format!("Failed to copy directory {:?} to {:?}", path, contents_path))?; + .with_context(|| format!("Failed to copy directory {path:?} to {contents_path:?}"))?; } } Ok(()) @@ -359,7 +355,7 @@ fn create_info_plist( // Copies the framework under `{src_dir}/{framework}.framework` to `{dest_dir}/{framework}.framework`. fn copy_framework_from(dest_dir: &Path, framework: &str, src_dir: &Path) -> crate::Result { - let src_name = format!("{}.framework", framework); + let src_name = format!("{framework}.framework"); let src_path = src_dir.join(&src_name); if src_path.exists() { fs_utils::copy_dir(&src_path, &dest_dir.join(&src_name))?; @@ -387,7 +383,7 @@ fn copy_frameworks_to_bundle( } let dest_dir = bundle_directory.join("Frameworks"); fs::create_dir_all(bundle_directory) - .with_context(|| format!("Failed to create Frameworks directory at {:?}", dest_dir))?; + .with_context(|| format!("Failed to create Frameworks directory at {dest_dir:?}"))?; for framework in frameworks.iter() { if framework.ends_with(".framework") { let src_path = PathBuf::from(framework); @@ -402,8 +398,7 @@ fn copy_frameworks_to_bundle( let src_path = PathBuf::from(framework); if !src_path.exists() { return Err(crate::Error::GenericError(format!( - "Library not found: {}", - framework + "Library not found: {framework}" ))); } let src_name = src_path.file_name().expect("Couldn't get library filename"); @@ -416,8 +411,7 @@ fn copy_frameworks_to_bundle( continue; } else if framework.contains('/') { return Err(crate::Error::GenericError(format!( - "Framework path should have .framework extension: {}", - framework + "Framework path should have .framework extension: {framework}" ))); } if let Some(home_dir) = dirs::home_dir() { @@ -435,8 +429,7 @@ fn copy_frameworks_to_bundle( continue; } return Err(crate::Error::GenericError(format!( - "Could not locate framework: {}", - framework + "Could not locate framework: {framework}" ))); } Ok(paths) diff --git a/crates/tauri-bundler/src/bundle/macos/dmg/mod.rs b/crates/tauri-bundler/src/bundle/macos/dmg/mod.rs index 979a1c027..bbc59e505 100644 --- a/crates/tauri-bundler/src/bundle/macos/dmg/mod.rs +++ b/crates/tauri-bundler/src/bundle/macos/dmg/mod.rs @@ -49,8 +49,7 @@ pub fn bundle_project(settings: &Settings, bundles: &[Bundle]) -> crate::Result< Arch::Universal => "universal", target => { return Err(crate::Error::ArchError(format!( - "Unsupported architecture: {:?}", - target + "Unsupported architecture: {target:?}" ))); } } @@ -59,7 +58,7 @@ pub fn bundle_project(settings: &Settings, bundles: &[Bundle]) -> crate::Result< let dmg_path = output_path.join(&dmg_name); let product_name = settings.product_name(); - let bundle_file_name = format!("{}.app", product_name); + let bundle_file_name = format!("{product_name}.app"); let bundle_dir = settings.project_out_directory().join("bundle/macos"); let support_directory_path = output_path @@ -69,10 +68,10 @@ pub fn bundle_project(settings: &Settings, bundles: &[Bundle]) -> crate::Result< for path in &[&support_directory_path, &output_path] { if path.exists() { - fs::remove_dir_all(path).with_context(|| format!("Failed to remove old {}", dmg_name))?; + fs::remove_dir_all(path).with_context(|| format!("Failed to remove old {dmg_name}"))?; } fs::create_dir_all(path) - .with_context(|| format!("Failed to create output directory at {:?}", path))?; + .with_context(|| format!("Failed to create output directory at {path:?}"))?; } // create paths for script diff --git a/crates/tauri-bundler/src/bundle/macos/ios.rs b/crates/tauri-bundler/src/bundle/macos/ios.rs index 421f43c63..1fbf8e28b 100644 --- a/crates/tauri-bundler/src/bundle/macos/ios.rs +++ b/crates/tauri-bundler/src/bundle/macos/ios.rs @@ -45,16 +45,16 @@ pub fn bundle_project(settings: &Settings) -> crate::Result> { if app_bundle_path.exists() { fs::remove_dir_all(&app_bundle_path) - .with_context(|| format!("Failed to remove old {}", app_product_name))?; + .with_context(|| format!("Failed to remove old {app_product_name}"))?; } fs::create_dir_all(&app_bundle_path) - .with_context(|| format!("Failed to create bundle directory at {:?}", app_bundle_path))?; + .with_context(|| format!("Failed to create bundle directory at {app_bundle_path:?}"))?; for src in settings.resource_files() { let src = src?; let dest = app_bundle_path.join(tauri_utils::resources::resource_relpath(&src)); fs_utils::copy_file(&src, &dest) - .with_context(|| format!("Failed to copy resource file {:?}", src))?; + .with_context(|| format!("Failed to copy resource file {src:?}"))?; } let icon_filenames = generate_icon_files(&app_bundle_path, settings) @@ -65,7 +65,7 @@ pub fn bundle_project(settings: &Settings) -> crate::Result> { for bin in settings.binaries() { let bin_path = settings.binary_path(bin); fs_utils::copy_file(&bin_path, &app_bundle_path.join(bin.name())) - .with_context(|| format!("Failed to copy binary from {:?}", bin_path))?; + .with_context(|| format!("Failed to copy binary from {bin_path:?}"))?; } Ok(vec![app_bundle_path]) @@ -197,7 +197,7 @@ fn generate_info_plist( if !icon_filenames.is_empty() { writeln!(file, " CFBundleIconFiles\n ")?; for filename in icon_filenames { - writeln!(file, " {}", filename)?; + writeln!(file, " {filename}")?; } writeln!(file, " ")?; } diff --git a/crates/tauri-bundler/src/bundle/windows/msi/mod.rs b/crates/tauri-bundler/src/bundle/windows/msi/mod.rs index 43c0f94f8..22426f123 100644 --- a/crates/tauri-bundler/src/bundle/windows/msi/mod.rs +++ b/crates/tauri-bundler/src/bundle/windows/msi/mod.rs @@ -177,7 +177,7 @@ impl ResourceDirectory { directories.push_str(wix_string.as_str()); } let wix_string = if self.name.is_empty() { - format!("{}{}", files, directories) + format!("{files}{directories}") } else { format!( r#"{files}{directories}"#, @@ -221,8 +221,7 @@ fn app_installer_output_path( Arch::AArch64 => "arm64", target => { return Err(crate::Error::ArchError(format!( - "Unsupported architecture: {:?}", - target + "Unsupported architecture: {target:?}" ))) } }; @@ -352,8 +351,7 @@ fn run_candle( Arch::AArch64 => "arm64", target => { return Err(crate::Error::ArchError(format!( - "unsupported architecture: {:?}", - target + "unsupported architecture: {target:?}" ))) } }; @@ -443,8 +441,7 @@ pub fn build_wix_app_installer( Arch::AArch64 => "arm64", target => { return Err(crate::Error::ArchError(format!( - "unsupported architecture: {:?}", - target + "unsupported architecture: {target:?}" ))) } }; @@ -845,7 +842,7 @@ pub fn build_wix_app_installer( let locale_contents = locale_contents.replace( "", - &format!("{}", unset_locale_strings), + &format!("{unset_locale_strings}"), ); let locale_path = output_path.join("locale.wxl"); { diff --git a/crates/tauri-bundler/src/bundle/windows/nsis/mod.rs b/crates/tauri-bundler/src/bundle/windows/nsis/mod.rs index 1bec36c45..cfa9096e4 100644 --- a/crates/tauri-bundler/src/bundle/windows/nsis/mod.rs +++ b/crates/tauri-bundler/src/bundle/windows/nsis/mod.rs @@ -177,8 +177,7 @@ fn build_nsis_app_installer( Arch::AArch64 => "arm64", target => { return Err(crate::Error::ArchError(format!( - "unsupported architecture: {:?}", - target + "unsupported architecture: {target:?}" ))) } }; diff --git a/crates/tauri-cli/src/acl/capability/new.rs b/crates/tauri-cli/src/acl/capability/new.rs index 32dc4269d..e3618dde3 100644 --- a/crates/tauri-cli/src/acl/capability/new.rs +++ b/crates/tauri-cli/src/acl/capability/new.rs @@ -98,7 +98,7 @@ pub fn command(options: Options) -> Result<()> { PermissionEntry::PermissionRef( p.clone() .try_into() - .unwrap_or_else(|_| panic!("invalid permission {}", p)), + .unwrap_or_else(|_| panic!("invalid permission {p}")), ) }) .collect(), diff --git a/crates/tauri-cli/src/helpers/mod.rs b/crates/tauri-cli/src/helpers/mod.rs index 3f0a9fc60..0fe4ed807 100644 --- a/crates/tauri-cli/src/helpers/mod.rs +++ b/crates/tauri-cli/src/helpers/mod.rs @@ -97,7 +97,7 @@ pub fn run_hook( .current_dir(cwd) .envs(env) .piped() - .with_context(|| format!("failed to run `{}` with `cmd /C`", script))?; + .with_context(|| format!("failed to run `{script}` with `cmd /C`"))?; #[cfg(not(target_os = "windows"))] let status = Command::new("sh") .arg("-c") diff --git a/crates/tauri-cli/src/info/env_system.rs b/crates/tauri-cli/src/info/env_system.rs index 54738cf75..88083b5b2 100644 --- a/crates/tauri-cli/src/info/env_system.rs +++ b/crates/tauri-cli/src/info/env_system.rs @@ -225,7 +225,7 @@ pub fn items() -> Vec { ); webview2_version() .map(|v| { - v.map(|v| (format!("WebView2: {}", v), Status::Success)) + v.map(|v| (format!("WebView2: {v}"), Status::Success)) .unwrap_or_else(|| (error.clone(), Status::Error)) }) .unwrap_or_else(|_| (error, Status::Error)).into() diff --git a/crates/tauri-cli/src/migrate/migrations/v1/manifest.rs b/crates/tauri-cli/src/migrate/migrations/v1/manifest.rs index 866159feb..07a312e8c 100644 --- a/crates/tauri-cli/src/migrate/migrations/v1/manifest.rs +++ b/crates/tauri-cli/src/migrate/migrations/v1/manifest.rs @@ -349,7 +349,7 @@ mod tests { [dependencies] tauri = {{ version = "1.0.0", features = [{}] }} "#, - features.iter().map(|f| format!("{:?}", f)).join(", ") + features.iter().map(|f| format!("{f:?}")).join(", ") ) }); } @@ -363,7 +363,7 @@ mod tests { version = "1.0.0" features = [{}] "#, - features.iter().map(|f| format!("{:?}", f)).join(", ") + features.iter().map(|f| format!("{f:?}")).join(", ") ) }); } diff --git a/crates/tauri-cli/src/mobile/android/project.rs b/crates/tauri-cli/src/mobile/android/project.rs index d24fdd49d..144c20346 100644 --- a/crates/tauri-cli/src/mobile/android/project.rs +++ b/crates/tauri-cli/src/mobile/android/project.rs @@ -110,7 +110,7 @@ pub fn gen( map.insert("windows", cfg!(windows)); let identifier = config.app().identifier().replace('.', "/"); - let package_path = format!("java/{}", identifier); + let package_path = format!("java/{identifier}"); map.insert("package-path", &package_path); diff --git a/crates/tauri-cli/src/mobile/init.rs b/crates/tauri-cli/src/mobile/init.rs index 2afa2c08f..cd5b99d0c 100644 --- a/crates/tauri-cli/src/mobile/init.rs +++ b/crates/tauri-cli/src/mobile/init.rs @@ -314,7 +314,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/crates/tauri-cli/src/mobile/ios/xcode_script.rs b/crates/tauri-cli/src/mobile/ios/xcode_script.rs index 2473bbf07..6b04e68fc 100644 --- a/crates/tauri-cli/src/mobile/ios/xcode_script.rs +++ b/crates/tauri-cli/src/mobile/ios/xcode_script.rs @@ -207,9 +207,9 @@ pub fn command(options: Options) -> Result<()> { Some(rust_triple.into()), )?; - let cflags = format!("CFLAGS_{}", env_triple); - let cxxflags = format!("CFLAGS_{}", env_triple); - let objc_include_path = format!("OBJC_INCLUDE_PATH_{}", env_triple); + let cflags = format!("CFLAGS_{env_triple}"); + let cxxflags = format!("CFLAGS_{env_triple}"); + let objc_include_path = format!("OBJC_INCLUDE_PATH_{env_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()); diff --git a/crates/tauri-cli/src/plugin/android.rs b/crates/tauri-cli/src/plugin/android.rs index 594514053..51322a57c 100644 --- a/crates/tauri-cli/src/plugin/android.rs +++ b/crates/tauri-cli/src/plugin/android.rs @@ -61,7 +61,7 @@ pub fn command(cli: Cli) -> Result<()> { let plugin_id = prompts::input( "What should be the Android Package ID for your plugin?", - Some(format!("com.plugin.{}", plugin_name)), + Some(format!("com.plugin.{plugin_name}")), false, false, )? @@ -114,17 +114,15 @@ tauri-build = "{}" let init_fn = format!( r#" pub fn init() -> TauriPlugin {{ - Builder::new("{name}") + Builder::new("{plugin_name}") .setup(|app, api| {{ #[cfg(target_os = "android")] - let handle = api.register_android_plugin("{identifier}", "ExamplePlugin")?; + let handle = api.register_android_plugin("{plugin_id}", "ExamplePlugin")?; Ok(()) }}) .build() }} -"#, - name = plugin_name, - identifier = plugin_id +"# ); log::info!("Android project added"); diff --git a/crates/tauri-cli/src/plugin/init.rs b/crates/tauri-cli/src/plugin/init.rs index 06317be77..39219fe48 100644 --- a/crates/tauri-cli/src/plugin/init.rs +++ b/crates/tauri-cli/src/plugin/init.rs @@ -156,7 +156,7 @@ pub fn command(mut options: Options) -> Result<()> { let plugin_id = if options.android || options.mobile { let plugin_id = prompts::input( "What should be the Android Package ID for your plugin?", - Some(format!("com.plugin.{}", plugin_name)), + Some(format!("com.plugin.{plugin_name}")), false, false, )? diff --git a/crates/tauri-cli/src/plugin/ios.rs b/crates/tauri-cli/src/plugin/ios.rs index f0be47f2a..88621954c 100644 --- a/crates/tauri-cli/src/plugin/ios.rs +++ b/crates/tauri-cli/src/plugin/ios.rs @@ -126,19 +126,18 @@ tauri-build = "{}" let init_fn = format!( r#" #[cfg(target_os = "ios")] -tauri::ios_plugin_binding!(init_plugin_{name}); +tauri::ios_plugin_binding!(init_plugin_{plugin_name}); pub fn init() -> TauriPlugin {{ - Builder::new("{name}") + Builder::new("{plugin_name}") .setup(|app| {{ #[cfg(target_os = "ios")] - app.register_ios_plugin(init_plugin_{name})?; + app.register_ios_plugin(init_plugin_{plugin_name})?; Ok(()) }}) .build() }} "#, - name = plugin_name, ); log::info!("iOS project added"); diff --git a/crates/tauri-driver/src/cli.rs b/crates/tauri-driver/src/cli.rs index f8e81b46f..4e38ebfc3 100644 --- a/crates/tauri-driver/src/cli.rs +++ b/crates/tauri-driver/src/cli.rs @@ -29,14 +29,14 @@ impl From for Args { fn from(mut args: pico_args::Arguments) -> Self { // if the user wanted help, we don't care about parsing the rest of the args if args.contains(["-h", "--help"]) { - println!("{}", HELP); + println!("{HELP}"); std::process::exit(0); } let native_driver = match args.opt_value_from_str("--native-driver") { Ok(native_driver) => native_driver, Err(e) => { - eprintln!("Error while parsing option --native-driver: {}", e); + eprintln!("Error while parsing option --native-driver: {e}"); std::process::exit(1); } }; @@ -53,8 +53,8 @@ impl From for Args { // be strict about accepting args, error for anything extraneous let rest = args.finish(); if !rest.is_empty() { - eprintln!("Error: unused arguments left: {:?}", rest); - eprintln!("{}", HELP); + eprintln!("Error: unused arguments left: {rest:?}"); + eprintln!("{HELP}"); std::process::exit(1); } diff --git a/crates/tauri-driver/src/main.rs b/crates/tauri-driver/src/main.rs index 8fee5da08..75795f91c 100644 --- a/crates/tauri-driver/src/main.rs +++ b/crates/tauri-driver/src/main.rs @@ -46,7 +46,7 @@ fn main() { // start our webdriver intermediary node if let Err(e) = server::run(args, driver) { - eprintln!("error while running server: {}", e); + eprintln!("error while running server: {e}"); std::process::exit(1); } } diff --git a/crates/tauri-driver/src/server.rs b/crates/tauri-driver/src/server.rs index 0433cf8e1..e0ffaa307 100644 --- a/crates/tauri-driver/src/server.rs +++ b/crates/tauri-driver/src/server.rs @@ -222,7 +222,7 @@ pub async fn run(args: Args, mut _driver: Child) -> Result<(), Error> { ) .await { - println!("Error serving connection: {:?}", err); + println!("Error serving connection: {err:?}"); } }); } else { @@ -230,7 +230,7 @@ pub async fn run(args: Args, mut _driver: Child) -> Result<(), Error> { } } } else { - println!("can not listen to address: {:?}", address); + println!("can not listen to address: {address:?}"); } }; srv.await; diff --git a/crates/tauri-driver/src/webdriver.rs b/crates/tauri-driver/src/webdriver.rs index 6de4d4142..76bb93884 100644 --- a/crates/tauri-driver/src/webdriver.rs +++ b/crates/tauri-driver/src/webdriver.rs @@ -25,7 +25,7 @@ pub fn native(args: &Args) -> Command { ); match current_dir() { Ok(cwd) => eprintln!("current working directory: {}", cwd.display()), - Err(error) => eprintln!("can not find current working directory: {}", error), + Err(error) => eprintln!("can not find current working directory: {error}"), } std::process::exit(1); } @@ -34,11 +34,10 @@ pub fn native(args: &Args) -> Command { Ok(binary) => binary, Err(error) => { eprintln!( - "can not find binary {} in the PATH. This is currently required.\ - You can also pass a custom path with --native-driver", - DRIVER_BINARY + "can not find binary {DRIVER_BINARY} in the PATH. This is currently required.\ + You can also pass a custom path with --native-driver" ); - eprintln!("{:?}", error); + eprintln!("{error:?}"); std::process::exit(1); } }, diff --git a/crates/tauri-macos-sign/src/keychain.rs b/crates/tauri-macos-sign/src/keychain.rs index 32ca9f37e..5c4f94743 100644 --- a/crates/tauri-macos-sign/src/keychain.rs +++ b/crates/tauri-macos-sign/src/keychain.rs @@ -187,7 +187,7 @@ impl Keychain { SigningIdentity::Team(t) => t.certificate_name(), SigningIdentity::Identifier(i) => i.clone(), }; - println!("Signing with identity \"{}\"", identity); + println!("Signing with identity \"{identity}\""); println!("Signing {}", path.display()); diff --git a/crates/tauri-macos-sign/src/keychain/identity.rs b/crates/tauri-macos-sign/src/keychain/identity.rs index 3e57a9072..185e50f92 100644 --- a/crates/tauri-macos-sign/src/keychain/identity.rs +++ b/crates/tauri-macos-sign/src/keychain/identity.rs @@ -42,21 +42,17 @@ impl Team { .and_then(|v| v.to_string().ok()); let name = if let Some(organization) = organization { - println!( - "found cert {:?} with organization {:?}", - common_name, organization - ); + println!("found cert {common_name:?} with organization {organization:?}"); organization } else { println!( - "found cert {:?} but failed to get organization; falling back to displaying common name", - common_name + "found cert {common_name:?} but failed to get organization; falling back to displaying common name" ); regex!(r"Apple Develop\w+: (.*) \(.+\)") .captures(&common_name) .map(|caps| caps[1].to_owned()) .unwrap_or_else(|| { - println!("regex failed to capture nice part of name in cert {:?}; falling back to displaying full name", common_name); + println!("regex failed to capture nice part of name in cert {common_name:?}; falling back to displaying full name"); common_name.clone() }) }; @@ -106,7 +102,7 @@ pub fn list(keychain_path: &Path) -> Result> { .into_iter() .flat_map(|(cert_prefix, cert)| { Team::from_x509(cert_prefix, cert).map_err(|err| { - eprintln!("{}", err); + eprintln!("{err}"); err }) }) diff --git a/crates/tauri-macos-sign/src/lib.rs b/crates/tauri-macos-sign/src/lib.rs index ea47c0f46..8a7bee343 100644 --- a/crates/tauri-macos-sign/src/lib.rs +++ b/crates/tauri-macos-sign/src/lib.rs @@ -130,7 +130,7 @@ pub fn notarize( submit_output.status, submit_output.id, submit_output.message ); if submit_output.status == "Accepted" { - println!("Notarizing {}", log_message); + println!("Notarizing {log_message}"); staple_app(app_bundle_path.to_path_buf())?; Ok(()) } else if let Ok(output) = Command::new("xcrun") diff --git a/crates/tauri-plugin/src/build/mobile.rs b/crates/tauri-plugin/src/build/mobile.rs index 3d4d3cec6..070c615b3 100644 --- a/crates/tauri-plugin/src/build/mobile.rs +++ b/crates/tauri-plugin/src/build/mobile.rs @@ -184,11 +184,11 @@ fn insert_into_xml(xml: &str, block_identifier: &str, parent_tag: &str, contents if let Some(index) = line.find(&parent_closing_tag) { let indentation = " ".repeat(index + 4); - rewritten.push(format!("{}{}", indentation, block_comment)); + rewritten.push(format!("{indentation}{block_comment}")); for l in contents.split('\n') { - rewritten.push(format!("{}{}", indentation, l)); + rewritten.push(format!("{indentation}{l}")); } - rewritten.push(format!("{}{}", indentation, block_comment)); + rewritten.push(format!("{indentation}{block_comment}")); } rewritten.push(line.to_string()); diff --git a/crates/tauri-utils/src/acl/build.rs b/crates/tauri-utils/src/acl/build.rs index 266b15e46..d43afc281 100644 --- a/crates/tauri-utils/src/acl/build.rs +++ b/crates/tauri-utils/src/acl/build.rs @@ -89,7 +89,7 @@ pub fn define_permissions bool>( .collect::>(); let pkg_name_valid_path = pkg_name.replace(':', "-"); - let permission_files_path = out_dir.join(format!("{}-permission-files", pkg_name_valid_path)); + let permission_files_path = out_dir.join(format!("{pkg_name_valid_path}-permission-files")); let permission_files_json = serde_json::to_string(&permission_files)?; fs::write(&permission_files_path, permission_files_json) .map_err(|e| Error::WriteFile(e, permission_files_path.clone()))?; diff --git a/crates/tauri-utils/src/config.rs b/crates/tauri-utils/src/config.rs index ca2439020..29db41d89 100644 --- a/crates/tauri-utils/src/config.rs +++ b/crates/tauri-utils/src/config.rs @@ -2156,7 +2156,7 @@ impl Display for HeaderSource { let len = m.len(); let mut i = 0; for (key, value) in m { - write!(f, "{} {}", key, value)?; + write!(f, "{key} {value}")?; i += 1; if i != len { write!(f, "; ")?; diff --git a/crates/tauri/src/protocol/isolation.rs b/crates/tauri/src/protocol/isolation.rs index 48927b0fd..f846ad4f4 100644 --- a/crates/tauri/src/protocol/isolation.rs +++ b/crates/tauri/src/protocol/isolation.rs @@ -45,7 +45,7 @@ pub fn get( &assets, &"index.html".into(), &manager, - Csp::Policy(format!("default-src 'none'; frame-src {}", frame_src)), + Csp::Policy(format!("default-src 'none'; frame-src {frame_src}")), ); let csp = Csp::DirectiveMap(csp_map).to_string(); diff --git a/examples/api/src-tauri/src/lib.rs b/examples/api/src-tauri/src/lib.rs index b057ea34c..0add41acb 100644 --- a/examples/api/src-tauri/src/lib.rs +++ b/examples/api/src-tauri/src/lib.rs @@ -86,7 +86,7 @@ pub fn run_app) + Send + 'static>( let response = app.sample().ping(PingRequest { value: value.clone(), on_event: Channel::new(|event| { - println!("got channel event: {:?}", event); + println!("got channel event: {event:?}"); Ok(()) }), }); @@ -102,7 +102,7 @@ pub fn run_app) + Send + 'static>( let server = match tiny_http::Server::http("localhost:3003") { Ok(s) => s, Err(e) => { - eprintln!("{}", e); + eprintln!("{e}"); std::process::exit(1); } }; diff --git a/examples/api/src-tauri/tauri-plugin-sample/src/lib.rs b/examples/api/src-tauri/tauri-plugin-sample/src/lib.rs index db923fa12..894b3481f 100644 --- a/examples/api/src-tauri/tauri-plugin-sample/src/lib.rs +++ b/examples/api/src-tauri/tauri-plugin-sample/src/lib.rs @@ -56,8 +56,8 @@ fn ping( scope: tauri::ipc::CommandScope, global_scope: tauri::ipc::GlobalScope, ) -> std::result::Result { - println!("local scope {:?}", scope); - println!("global scope {:?}", global_scope); + println!("local scope {scope:?}"); + println!("global scope {global_scope:?}"); app .sample() .ping(PingRequest { diff --git a/examples/resources/src-tauri/src/main.rs b/examples/resources/src-tauri/src/main.rs index 42640ce61..3c3ddae4f 100644 --- a/examples/resources/src-tauri/src/main.rs +++ b/examples/resources/src-tauri/src/main.rs @@ -22,7 +22,7 @@ fn main() { let content = std::fs::read_to_string(&path).unwrap(); println!("Resource `assets/index.js` path: {}", path.display()); - println!("Resource `assets/index.js` content:\n{}\n", content); + println!("Resource `assets/index.js` content:\n{content}\n"); Ok(()) }) diff --git a/packages/cli/src/lib.rs b/packages/cli/src/lib.rs index 034c8f49b..a031b17da 100644 --- a/packages/cli/src/lib.rs +++ b/packages/cli/src/lib.rs @@ -35,7 +35,7 @@ pub fn run(args: Vec, bin_name: Option, callback: JsFunction) -> match res { Ok(_) => function.call(Ok(true), ThreadsafeFunctionCallMode::Blocking), Err(e) => function.call( - Err(Error::new(Status::GenericFailure, format!("{:#}", e))), + Err(Error::new(Status::GenericFailure, format!("{e:#}"))), ThreadsafeFunctionCallMode::Blocking, ), }