diff --git a/core/config-schema/build.rs b/core/config-schema/build.rs index fd0097699..0c5fe9898 100644 --- a/core/config-schema/build.rs +++ b/core/config-schema/build.rs @@ -18,7 +18,7 @@ pub fn main() -> Result<(), Box> { crate_dir.join("../../tooling/cli/schema.json"), ] { let mut schema_file = BufWriter::new(File::create(&file)?); - write!(schema_file, "{}", schema_str)?; + write!(schema_file, "{schema_str}")?; } Ok(()) diff --git a/core/tauri-build/src/codegen/context.rs b/core/tauri-build/src/codegen/context.rs index 2d681229d..a21591fe3 100644 --- a/core/tauri-build/src/codegen/context.rs +++ b/core/tauri-build/src/codegen/context.rs @@ -86,7 +86,7 @@ impl CodegenContext { pub fn build(self) -> PathBuf { match self.try_build() { Ok(out) => out, - Err(error) => panic!("Error found during Codegen::build: {}", error), + Err(error) => panic!("Error found during Codegen::build: {error}"), } } @@ -161,7 +161,7 @@ impl CodegenContext { ) })?; - writeln!(file, "{}", code).with_context(|| { + writeln!(file, "{code}").with_context(|| { format!( "Unable to write tokenstream to out file during tauri-build {}", out.display() diff --git a/core/tauri-build/src/lib.rs b/core/tauri-build/src/lib.rs index 3ab1f4652..2b5c2251c 100644 --- a/core/tauri-build/src/lib.rs +++ b/core/tauri-build/src/lib.rs @@ -35,8 +35,8 @@ fn copy_file(from: impl AsRef, to: impl AsRef) -> Result<()> { Ok(()) } -fn copy_binaries<'a>( - binaries: ResourcePaths<'a>, +fn copy_binaries( + binaries: ResourcePaths, target_triple: &str, path: &Path, package_name: Option<&String>, @@ -48,7 +48,7 @@ fn copy_binaries<'a>( .file_name() .expect("failed to extract external binary filename") .to_string_lossy() - .replace(&format!("-{}", target_triple), ""); + .replace(&format!("-{target_triple}"), ""); if package_name.map_or(false, |n| n == &file_name) { return Err(anyhow::anyhow!( @@ -90,7 +90,7 @@ fn has_feature(feature: &str) -> bool { // `alias` must be a snake case string. fn cfg_alias(alias: &str, has_feature: bool) { if has_feature { - println!("cargo:rustc-cfg={}", alias); + println!("cargo:rustc-cfg={alias}"); } } @@ -227,8 +227,8 @@ impl Attributes { /// This is typically desirable when running inside a build script; see [`try_build`] for no panics. pub fn build() { if let Err(error) = try_build(Attributes::default()) { - let error = format!("{:#}", error); - println!("{}", error); + let error = format!("{error:#}"); + println!("{error}"); if error.starts_with("unknown field") { print!("found an unknown configuration field. This usually means that you are using a CLI version that is newer than `tauri-build` and is incompatible. "); println!( diff --git a/core/tauri-codegen/src/context.rs b/core/tauri-codegen/src/context.rs index b7803436d..e562dba20 100644 --- a/core/tauri-codegen/src/context.rs +++ b/core/tauri-codegen/src/context.rs @@ -141,7 +141,7 @@ pub fn context_codegen(data: ContextData) -> Result Result) -> fmt::Result { match self { - Self::External(url) => write!(f, "{}", url), + Self::External(url) => write!(f, "{url}"), Self::App(path) => write!(f, "{}", path.display()), } } @@ -125,7 +125,7 @@ impl<'de> Deserialize<'de> for BundleType { "app" => Ok(Self::App), "dmg" => Ok(Self::Dmg), "updater" => Ok(Self::Updater), - _ => Err(DeError::custom(format!("unknown bundle target '{}'", s))), + _ => Err(DeError::custom(format!("unknown bundle target '{s}'"))), } } } @@ -223,7 +223,7 @@ impl<'de> Deserialize<'de> for BundleTarget { match BundleTargetInner::deserialize(deserializer)? { BundleTargetInner::All(s) if s.to_lowercase() == "all" => Ok(Self::All), - BundleTargetInner::All(t) => Err(DeError::custom(format!("invalid bundle type {}", t))), + BundleTargetInner::All(t) => Err(DeError::custom(format!("invalid bundle type {t}"))), BundleTargetInner::List(l) => Ok(Self::List(l)), BundleTargetInner::One(t) => Ok(Self::One(t)), } @@ -994,7 +994,7 @@ impl CspDirectiveSources { /// Whether the given source is configured on this directive or not. pub fn contains(&self, source: &str) -> bool { match self { - Self::Inline(s) => s.contains(&format!("{} ", source)) || s.contains(&format!(" {}", source)), + Self::Inline(s) => s.contains(&format!("{source} ")) || s.contains(&format!(" {source}")), Self::List(l) => l.contains(&source.into()), } } @@ -1060,7 +1060,7 @@ impl From for HashMap { impl Display for Csp { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - Self::Policy(s) => write!(f, "{}", s), + Self::Policy(s) => write!(f, "{s}"), Self::DirectiveMap(m) => { let len = m.len(); let mut i = 0; @@ -2365,8 +2365,7 @@ impl<'de> Deserialize<'de> for WindowsUpdateInstallMode { "quiet" => Ok(Self::Quiet), "passive" => Ok(Self::Passive), _ => Err(DeError::custom(format!( - "unknown update install mode '{}'", - s + "unknown update install mode '{s}'" ))), } } @@ -2510,7 +2509,7 @@ pub enum AppUrl { impl std::fmt::Display for AppUrl { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - Self::Url(url) => write!(f, "{}", url), + Self::Url(url) => write!(f, "{url}"), Self::Files(files) => write!(f, "{}", serde_json::to_string(files).unwrap()), } } @@ -2649,9 +2648,9 @@ impl<'d> serde::Deserialize<'d> for PackageVersion { let path = PathBuf::from(value); if path.exists() { let json_str = read_to_string(&path) - .map_err(|e| DeError::custom(format!("failed to read version JSON file: {}", e)))?; + .map_err(|e| DeError::custom(format!("failed to read version JSON file: {e}")))?; let package_json: serde_json::Value = serde_json::from_str(&json_str) - .map_err(|e| DeError::custom(format!("failed to read version JSON file: {}", e)))?; + .map_err(|e| DeError::custom(format!("failed to read version JSON file: {e}")))?; if let Some(obj) = package_json.as_object() { let version = obj .get("version") diff --git a/core/tauri-utils/src/html.rs b/core/tauri-utils/src/html.rs index b8744261b..77bc8b800 100644 --- a/core/tauri-utils/src/html.rs +++ b/core/tauri-utils/src/html.rs @@ -37,7 +37,7 @@ fn serialize_node_ref_internal( traversal_scope: TraversalScope, ) -> crate::Result<()> { match (traversal_scope, node.data()) { - (ref scope, &NodeData::Element(ref element)) => { + (ref scope, NodeData::Element(element)) => { if *scope == TraversalScope::IncludeNode { let attrs = element.attributes.borrow(); @@ -82,16 +82,16 @@ fn serialize_node_ref_internal( (TraversalScope::ChildrenOnly(_), _) => Ok(()), - (TraversalScope::IncludeNode, &NodeData::Doctype(ref doctype)) => { + (TraversalScope::IncludeNode, NodeData::Doctype(doctype)) => { serializer.write_doctype(&doctype.name).map_err(Into::into) } - (TraversalScope::IncludeNode, &NodeData::Text(ref text)) => { + (TraversalScope::IncludeNode, NodeData::Text(text)) => { serializer.write_text(&text.borrow()).map_err(Into::into) } - (TraversalScope::IncludeNode, &NodeData::Comment(ref text)) => { + (TraversalScope::IncludeNode, NodeData::Comment(text)) => { serializer.write_comment(&text.borrow()).map_err(Into::into) } - (TraversalScope::IncludeNode, &NodeData::ProcessingInstruction(ref contents)) => { + (TraversalScope::IncludeNode, NodeData::ProcessingInstruction(contents)) => { let contents = contents.borrow(); serializer .write_processing_instruction(&contents.0, &contents.1) diff --git a/core/tauri-utils/src/mime_type.rs b/core/tauri-utils/src/mime_type.rs index be2471ea9..60bd08f0e 100644 --- a/core/tauri-utils/src/mime_type.rs +++ b/core/tauri-utils/src/mime_type.rs @@ -39,7 +39,7 @@ impl std::fmt::Display for MimeType { MimeType::Svg => "image/svg+xml", MimeType::Mp4 => "video/mp4", }; - write!(f, "{}", mime) + write!(f, "{mime}") } } diff --git a/core/tauri-utils/src/platform.rs b/core/tauri-utils/src/platform.rs index 96614ffa2..d16f275e8 100644 --- a/core/tauri-utils/src/platform.rs +++ b/core/tauri-utils/src/platform.rs @@ -133,10 +133,10 @@ pub fn target_triple() -> crate::Result { return Err(crate::Error::Environment); }; - format!("{}-{}", os, env) + format!("{os}-{env}") }; - Ok(format!("{}-{}", arch, os)) + Ok(format!("{arch}-{os}")) } /// Computes the resource directory of the current environment. @@ -157,8 +157,8 @@ pub fn resource_dir(package_info: &PackageInfo, env: &Env) -> crate::Result bool { // `alias` must be a snake case string. fn alias(alias: &str, has_feature: bool) { if has_feature { - println!("cargo:rustc-cfg={}", alias); + println!("cargo:rustc-cfg={alias}"); } } @@ -137,8 +137,8 @@ fn main() { let checked_features_out_path = Path::new(&std::env::var("OUT_DIR").unwrap()).join("checked_features"); std::fs::write( - &checked_features_out_path, - &CHECKED_FEATURES.get().unwrap().lock().unwrap().join(","), + checked_features_out_path, + CHECKED_FEATURES.get().unwrap().lock().unwrap().join(","), ) .expect("failed to write checked_features file"); } @@ -153,14 +153,14 @@ fn main() { // // Note that both `module` and `apis` strings must be written in kebab case. fn alias_module(module: &str, apis: &[&str], api_all: bool) { - let all_feature_name = format!("{}-all", module); + let all_feature_name = format!("{module}-all"); let all = has_feature(&all_feature_name) || api_all; alias(&all_feature_name.to_snake_case(), all); let mut any = all; for api in apis { - let has = has_feature(&format!("{}-{}", module, api)) || all; + let has = has_feature(&format!("{module}-{api}")) || all; alias( &format!("{}_{}", AsSnakeCase(module), AsSnakeCase(api)), has, diff --git a/core/tauri/src/api/dir.rs b/core/tauri/src/api/dir.rs index 771a8925e..77aa2323a 100644 --- a/core/tauri/src/api/dir.rs +++ b/core/tauri/src/api/dir.rs @@ -226,7 +226,7 @@ mod test { fn check_test_dir() { // create a callback closure that takes in a TempDir type and prints it. let callback = |td: &tempfile::TempDir| { - println!("{:?}", td); + println!("{td:?}"); }; // execute the with_temp_dir function on the callback diff --git a/core/tauri/src/api/file/extract.rs b/core/tauri/src/api/file/extract.rs index 28e2ad9a4..4625981a0 100644 --- a/core/tauri/src/api/file/extract.rs +++ b/core/tauri/src/api/file/extract.rs @@ -150,7 +150,7 @@ impl<'a, R: std::fmt::Debug + Read + Seek> std::fmt::Debug for Extract<'a, R> { impl<'a, R: Read + Seek> Extract<'a, R> { /// Create archive from reader. pub fn from_cursor(mut reader: R, archive_format: ArchiveFormat) -> Extract<'a, R> { - if reader.seek(io::SeekFrom::Start(0)).is_err() { + if reader.rewind().is_err() { #[cfg(debug_assertions)] eprintln!("Could not seek to start of the file"); } diff --git a/core/tauri/src/api/http.rs b/core/tauri/src/api/http.rs index 70ab40388..a55529ddd 100644 --- a/core/tauri/src/api/http.rs +++ b/core/tauri/src/api/http.rs @@ -368,7 +368,7 @@ impl TryFrom for Vec { type Error = crate::api::Error; fn try_from(file: FilePart) -> crate::api::Result { let bytes = match file { - FilePart::Path(path) => std::fs::read(&path)?, + FilePart::Path(path) => std::fs::read(path)?, FilePart::Contents(bytes) => bytes, }; Ok(bytes) @@ -441,8 +441,7 @@ impl<'de> Deserialize<'de> for HeaderMap { headers.insert(key, value); } else { return Err(serde::de::Error::custom(format!( - "invalid header `{}` `{}`", - key, value + "invalid header `{key}` `{value}`" ))); } } diff --git a/core/tauri/src/api/ipc.rs b/core/tauri/src/api/ipc.rs index cbffb02e0..f09be3232 100644 --- a/core/tauri/src/api/ipc.rs +++ b/core/tauri/src/api/ipc.rs @@ -242,22 +242,22 @@ mod test { } let raw_str = "T".repeat(MIN_JSON_PARSE_LEN); - assert_eq!(serialize_js(&raw_str).unwrap(), format!("\"{}\"", raw_str)); + assert_eq!(serialize_js(&raw_str).unwrap(), format!("\"{raw_str}\"")); assert_eq!( serialize_js(&JsonObj { value: raw_str.clone() }) .unwrap(), - format!("JSON.parse('{{\"value\":\"{}\"}}')", raw_str) + format!("JSON.parse('{{\"value\":\"{raw_str}\"}}')") ); assert_eq!( serialize_js(&JsonObj { - value: format!("\"{}\"", raw_str) + value: format!("\"{raw_str}\"") }) .unwrap(), - format!("JSON.parse('{{\"value\":\"\\\\\"{}\\\\\"\"}}')", raw_str) + format!("JSON.parse('{{\"value\":\"\\\\\"{raw_str}\\\\\"\"}}')") ); let dangerous_json = RawValue::from_string( diff --git a/core/tauri/src/api/shell.rs b/core/tauri/src/api/shell.rs index 29b9d16f5..f9db17f36 100644 --- a/core/tauri/src/api/shell.rs +++ b/core/tauri/src/api/shell.rs @@ -112,5 +112,5 @@ pub fn open>( ) -> crate::api::Result<()> { scope .open(path.as_ref(), with) - .map_err(|err| crate::api::Error::Shell(format!("failed to open: {}", err))) + .map_err(|err| crate::api::Error::Shell(format!("failed to open: {err}"))) } diff --git a/core/tauri/src/app.rs b/core/tauri/src/app.rs index f8a76323d..779f4cc10 100644 --- a/core/tauri/src/app.rs +++ b/core/tauri/src/app.rs @@ -1290,8 +1290,7 @@ impl Builder { let type_name = std::any::type_name::(); assert!( self.state.set(state), - "state for type '{}' is already being managed", - type_name + "state for type '{type_name}' is already being managed" ); self } diff --git a/core/tauri/src/endpoints.rs b/core/tauri/src/endpoints.rs index 9dd2ca974..4106a4d04 100644 --- a/core/tauri/src/endpoints.rs +++ b/core/tauri/src/endpoints.rs @@ -238,8 +238,7 @@ pub(crate) fn handle( if let Some(unknown_variant_name) = s.next() { if unknown_variant_name == module { return resolver.reject(format!( - "The `{}` module is not enabled. You must enable one of its APIs in the allowlist.", - module + "The `{module}` module is not enabled. You must enable one of its APIs in the allowlist." )); } else if module == "Window" { return resolver.reject(window::into_allowlist_error(unknown_variant_name).to_string()); diff --git a/core/tauri/src/endpoints/event.rs b/core/tauri/src/endpoints/event.rs index 6d21d9316..8dd42f7af 100644 --- a/core/tauri/src/endpoints/event.rs +++ b/core/tauri/src/endpoints/event.rs @@ -138,7 +138,7 @@ impl Cmd { serde_json::to_string(&p) .map_err(|e| { #[cfg(debug_assertions)] - eprintln!("{}", e); + eprintln!("{e}"); e }) .ok() diff --git a/core/tauri/src/endpoints/shell.rs b/core/tauri/src/endpoints/shell.rs index 57aaf7db9..c85168549 100644 --- a/core/tauri/src/endpoints/shell.rs +++ b/core/tauri/src/endpoints/shell.rs @@ -135,7 +135,7 @@ impl Cmd { Ok(cmd) => cmd, Err(e) => { #[cfg(debug_assertions)] - eprintln!("{}", e); + eprintln!("{e}"); return Err(crate::Error::ProgramNotAllowed(PathBuf::from(program)).into_anyhow()); } } @@ -154,7 +154,7 @@ impl Cmd { if let Some(encoding) = crate::api::process::Encoding::for_label(encoding.as_bytes()) { command = command.encoding(encoding); } else { - return Err(anyhow::anyhow!(format!("unknown encoding {}", encoding))); + return Err(anyhow::anyhow!(format!("unknown encoding {encoding}"))); } } let (mut rx, child) = command.spawn()?; diff --git a/core/tauri/src/event.rs b/core/tauri/src/event.rs index d19fed996..1605be2bc 100644 --- a/core/tauri/src/event.rs +++ b/core/tauri/src/event.rs @@ -232,7 +232,7 @@ mod test { // dummy event handler function fn event_fn(s: Event) { - println!("{:?}", s); + println!("{s:?}"); } proptest! { @@ -304,18 +304,15 @@ pub fn unlisten_js(listeners_object_name: String, event_name: String, event_id: format!( " (function () {{ - const listeners = (window['{listeners}'] || {{}})['{event_name}'] + const listeners = (window['{listeners_object_name}'] || {{}})['{event_name}'] if (listeners) {{ - const index = window['{listeners}']['{event_name}'].findIndex(e => e.id === {event_id}) + const index = window['{listeners_object_name}']['{event_name}'].findIndex(e => e.id === {event_id}) if (index > -1) {{ - window['{listeners}']['{event_name}'].splice(index, 1) + window['{listeners_object_name}']['{event_name}'].splice(index, 1) }} }} }})() ", - listeners = listeners_object_name, - event_name = event_name, - event_id = event_id, ) } @@ -353,7 +350,7 @@ pub fn listen_js( event_id = event_id, window_label = if let Some(l) = window_label { crate::runtime::window::assert_label_is_valid(&l); - format!("'{}'", l) + format!("'{l}'") } else { "null".to_owned() }, diff --git a/core/tauri/src/hooks.rs b/core/tauri/src/hooks.rs index 8d992b770..bd2337d69 100644 --- a/core/tauri/src/hooks.rs +++ b/core/tauri/src/hooks.rs @@ -99,7 +99,7 @@ impl InvokeError { /// Create an [`InvokeError`] as a string of the [`anyhow::Error`] message. #[inline(always)] pub fn from_anyhow(error: anyhow::Error) -> Self { - Self(JsonValue::String(format!("{:#}", error))) + Self(JsonValue::String(format!("{error:#}"))) } } diff --git a/core/tauri/src/lib.rs b/core/tauri/src/lib.rs index 3ccfb74dd..4017b980a 100644 --- a/core/tauri/src/lib.rs +++ b/core/tauri/src/lib.rs @@ -440,8 +440,7 @@ impl TryFrom for runtime::Icon { }) } _ => panic!( - "image `{}` extension not supported; please file a Tauri feature request. `png` or `ico` icons are supported with the `icon-png` and `icon-ico` feature flags", - extension + "image `{extension}` extension not supported; please file a Tauri feature request. `png` or `ico` icons are supported with the `icon-png` and `icon-ico` feature flags" ), } } @@ -845,8 +844,8 @@ mod tests { let lib_code = read_to_string(manifest_dir.join("src/lib.rs")).expect("failed to read lib.rs"); for f in get_manifest().features.keys() { - if !(f.starts_with("__") || f == "default" || lib_code.contains(&format!("*{}**", f))) { - panic!("Feature {} is not documented", f); + if !(f.starts_with("__") || f == "default" || lib_code.contains(&format!("*{f}**"))) { + panic!("Feature {f} is not documented"); } } } @@ -858,8 +857,7 @@ mod tests { for checked_feature in checked_features { if !manifest.features.iter().any(|(f, _)| f == checked_feature) { panic!( - "Feature {} was checked in the alias build step but it does not exist in core/tauri/Cargo.toml", - checked_feature + "Feature {checked_feature} was checked in the alias build step but it does not exist in core/tauri/Cargo.toml" ); } } @@ -895,24 +893,20 @@ mod tests { let module = module_all_feature.replace("-all", ""); assert!( checked_features.contains(&module_all_feature.as_str()), - "`{}` is not aliased", - module + "`{module}` is not aliased" ); - let module_prefix = format!("{}-", module); + let module_prefix = format!("{module}-"); // we assume that module features are the ones that start with `-` // though it's not 100% accurate, we have an allowed list to fix it let module_features = manifest - .features - .iter() - .map(|(f, _)| f) + .features.keys() .filter(|f| f.starts_with(&module_prefix)); for module_feature in module_features { assert!( allowed.contains(&module_feature.as_str()) || checked_features.contains(&module_feature.as_str()), - "`{}` is not aliased", - module_feature + "`{module_feature}` is not aliased" ); } } @@ -940,7 +934,7 @@ mod test_utils { fn check_spawn_task(task in "[a-z]+") { // create dummy task function let dummy_task = async move { - format!("{}-run-dummy-task", task); + format!("{task}-run-dummy-task"); }; // call spawn crate::async_runtime::spawn(dummy_task); diff --git a/core/tauri/src/manager.rs b/core/tauri/src/manager.rs index cdb100e8a..f2de52184 100644 --- a/core/tauri/src/manager.rs +++ b/core/tauri/src/manager.rs @@ -184,7 +184,7 @@ fn replace_csp_nonce( if !(nonces.is_empty() && hashes.is_empty()) { let nonce_sources = nonces .into_iter() - .map(|n| format!("'nonce-{}'", n)) + .map(|n| format!("'nonce-{n}'")) .collect::>(); let sources = csp.entry(directive.into()).or_insert_with(Default::default); let self_source = "'self'".to_string(); @@ -487,7 +487,7 @@ impl WindowManager { window_url.scheme(), window_url.host().unwrap(), if let Some(port) = window_url.port() { - format!(":{}", port) + format!(":{port}") } else { "".into() } @@ -714,7 +714,7 @@ impl WindowManager { { let assets = assets.clone(); let schema_ = schema.clone(); - let url_base = format!("{}://localhost", schema_); + let url_base = format!("{schema_}://localhost"); let aes_gcm_key = *crypto_keys.aes_gcm().raw(); pending.register_uri_scheme_protocol(schema, move |request| { @@ -813,7 +813,7 @@ impl WindowManager { let asset_response = assets .get(&path.as_str().into()) .or_else(|| { - eprintln!("Asset `{}` not found; fallback to {}.html", path, path); + eprintln!("Asset `{path}` not found; fallback to {path}.html"); let fallback = format!("{}.html", path.as_str()).into(); let asset = assets.get(&fallback); asset_path = fallback; @@ -1408,8 +1408,7 @@ fn on_window_event( let windows = windows_map.values(); for window in windows { window.eval(&format!( - r#"(function () {{ const metadata = window.__TAURI_METADATA__; if (metadata != null) {{ metadata.__windows = window.__TAURI_METADATA__.__windows.filter(w => w.label !== "{}"); }} }})()"#, - label + r#"(function () {{ const metadata = window.__TAURI_METADATA__; if (metadata != null) {{ metadata.__windows = window.__TAURI_METADATA__.__windows.filter(w => w.label !== "{label}"); }} }})()"# ))?; } } diff --git a/core/tauri/src/pattern.rs b/core/tauri/src/pattern.rs index 660959dbb..0a52fe8af 100644 --- a/core/tauri/src/pattern.rs +++ b/core/tauri/src/pattern.rs @@ -87,8 +87,8 @@ pub(crate) struct PatternJavascript { #[allow(dead_code)] pub(crate) fn format_real_schema(schema: &str) -> String { if cfg!(windows) { - format!("https://{}.localhost", schema) + format!("https://{schema}.localhost") } else { - format!("{}://localhost", schema) + format!("{schema}://localhost") } } diff --git a/core/tauri/src/plugin.rs b/core/tauri/src/plugin.rs index d7aac7b8c..a7b8cb0a1 100644 --- a/core/tauri/src/plugin.rs +++ b/core/tauri/src/plugin.rs @@ -545,7 +545,7 @@ impl PluginStore { .values() .filter_map(|p| p.initialization_script()) .fold(String::new(), |acc, script| { - format!("{}\n(function () {{ {} }})();", acc, script) + format!("{acc}\n(function () {{ {script} }})();") }) } @@ -588,7 +588,7 @@ impl PluginStore { } else { invoke .resolver - .reject(format!("plugin {} not found", target)); + .reject(format!("plugin {target} not found")); } } } diff --git a/core/tauri/src/scope/http.rs b/core/tauri/src/scope/http.rs index 627b96d17..e96eb5831 100644 --- a/core/tauri/src/scope/http.rs +++ b/core/tauri/src/scope/http.rs @@ -21,7 +21,7 @@ impl Scope { .iter() .map(|url| { glob::Pattern::new(url.as_str()) - .unwrap_or_else(|_| panic!("scoped URL is not a valid glob pattern: `{}`", url)) + .unwrap_or_else(|_| panic!("scoped URL is not a valid glob pattern: `{url}`")) }) .collect(), } diff --git a/core/tauri/src/updater/core.rs b/core/tauri/src/updater/core.rs index 57085bcfd..e263ccd7c 100644 --- a/core/tauri/src/updater/core.rs +++ b/core/tauri/src/updater/core.rs @@ -96,7 +96,7 @@ impl<'de> Deserialize<'de> for RemoteRelease { let pub_date = if let Some(date) = release.pub_date { Some( OffsetDateTime::parse(&date, &time::format_description::well_known::Rfc3339) - .map_err(|e| DeError::custom(format!("invalid value for `pub_date`: {}", e)))?, + .map_err(|e| DeError::custom(format!("invalid value for `pub_date`: {e}")))?, ) } else { None @@ -336,7 +336,7 @@ impl UpdateBuilder { (target.clone(), target) } else { let target = get_updater_target().ok_or(Error::UnsupportedOs)?; - (target.to_string(), format!("{}-{}", target, arch)) + (target.to_string(), format!("{target}-{arch}")) }; // Get the extract_path from the provided executable_path @@ -1049,14 +1049,13 @@ mod test { format!( r#" {{ - "name": "v{}", + "name": "v{version}", "notes": "This is the latest version! Once updated you shouldn't see this prompt.", "pub_date": "2020-06-25T14:14:19Z", - "signature": "{}", - "url": "{}" + "signature": "{public_signature}", + "url": "{download_url}" }} - "#, - version, public_signature, download_url + "# ) } @@ -1069,15 +1068,14 @@ mod test { format!( r#" {{ - "name": "v{}", + "name": "v{version}", "notes": "This is the latest version! Once updated you shouldn't see this prompt.", "pub_date": "2020-06-25T14:14:19Z", - "signature": "{}", - "url": "{}", - "with_elevated_task": {} + "signature": "{public_signature}", + "url": "{download_url}", + "with_elevated_task": {with_elevated_task} }} - "#, - version, public_signature, download_url, with_elevated_task + "# ) } @@ -1515,7 +1513,7 @@ mod test { }"#; fn missing_field_error(field: &str) -> String { - format!("the `{}` field was not set on the updater response", field) + format!("the `{field}` field was not set on the updater response") } let test_cases = [ @@ -1547,7 +1545,7 @@ mod test { .target("test-target") .build()); if let Err(e) = check_update { - println!("ERROR: {}, expected: {}", e, error); + println!("ERROR: {e}, expected: {error}"); assert!(e.to_string().contains(&error)); } else { panic!("unexpected Ok response"); diff --git a/core/tauri/src/updater/mod.rs b/core/tauri/src/updater/mod.rs index e235d8e49..240c06bc8 100644 --- a/core/tauri/src/updater/mod.rs +++ b/core/tauri/src/updater/mod.rs @@ -109,7 +109,7 @@ pub const EVENT_STATUS_UPTODATE: &str = "UPTODATE"; /// Gets the target string used on the updater. pub fn target() -> Option { if let (Some(target), Some(arch)) = (core::get_updater_target(), core::get_updater_arch()) { - Some(format!("{}-{}", target, arch)) + Some(format!("{target}-{arch}")) } else { None } @@ -565,7 +565,7 @@ async fn prompt_for_install( // something more conventional. let should_install = ask( parent_window, - format!(r#"A new version of {} is available! "#, app_name), + format!(r#"A new version of {app_name} is available! "#), format!( r#"{} {} is now available -- you have {}. diff --git a/core/tests/app-updater/src/main.rs b/core/tests/app-updater/src/main.rs index d957fa1fd..f0ffd2a75 100644 --- a/core/tests/app-updater/src/main.rs +++ b/core/tests/app-updater/src/main.rs @@ -15,13 +15,13 @@ fn main() { match handle.updater().check().await { Ok(update) => { if let Err(e) = update.download_and_install().await { - println!("{}", e); + println!("{e}"); std::process::exit(1); } std::process::exit(0); } Err(e) => { - println!("{}", e); + println!("{e}"); std::process::exit(1); } } diff --git a/core/tests/app-updater/tests/update.rs b/core/tests/app-updater/tests/update.rs index c47261711..996852bc2 100644 --- a/core/tests/app-updater/tests/update.rs +++ b/core/tests/app-updater/tests/update.rs @@ -55,12 +55,12 @@ fn get_cli_bin_path(cli_dir: &Path, debug: bool) -> Option { } fn build_app(cli_bin_path: &Path, cwd: &Path, config: &Config, bundle_updater: bool) { - let mut command = Command::new(&cli_bin_path); + let mut command = Command::new(cli_bin_path); command .args(["build", "--debug", "--verbose"]) .arg("--config") .arg(serde_json::to_string(config).unwrap()) - .current_dir(&cwd); + .current_dir(cwd); #[cfg(windows)] command.args(["--bundles", "msi"]); @@ -88,8 +88,7 @@ fn build_app(cli_bin_path: &Path, cwd: &Path, config: &Config, bundle_updater: b #[cfg(target_os = "linux")] fn bundle_path(root_dir: &Path, version: &str) -> PathBuf { root_dir.join(format!( - "target/debug/bundle/appimage/app-updater_{}_amd64.AppImage", - version + "target/debug/bundle/appimage/app-updater_{version}_amd64.AppImage" )) } diff --git a/core/tests/restart/src/main.rs b/core/tests/restart/src/main.rs index 3a6848c57..b03243562 100644 --- a/core/tests/restart/src/main.rs +++ b/core/tests/restart/src/main.rs @@ -24,7 +24,7 @@ fn main() { env.args.clear(); tauri::api::process::restart(&env) } - Some(invalid) => panic!("only argument `restart` is allowed, {} is invalid", invalid), + Some(invalid) => panic!("only argument `restart` is allowed, {invalid} is invalid"), None => {} }; } diff --git a/core/tests/restart/tests/restart.rs b/core/tests/restart/tests/restart.rs index 3a6662ec1..db458a4eb 100644 --- a/core/tests/restart/tests/restart.rs +++ b/core/tests/restart/tests/restart.rs @@ -32,7 +32,7 @@ fn symlink_runner(create_symlinks: impl Fn(&Path) -> io::Result) -> Res if cfg!(windows) { compiled_binary.set_extension("exe"); } - println!("{:?}", compiled_binary); + println!("{compiled_binary:?}"); // set up all the temporary file paths let temp = tempfile::TempDir::new()?; diff --git a/examples/commands/commands.rs b/examples/commands/commands.rs index 3689569c8..f9c1c4442 100644 --- a/examples/commands/commands.rs +++ b/examples/commands/commands.rs @@ -18,7 +18,7 @@ pub fn resolver(_argument: String) {} #[command] pub fn simple_command(the_argument: String) { - println!("{}", the_argument); + println!("{the_argument}"); } #[command] diff --git a/examples/commands/main.rs b/examples/commands/main.rs index 5821eacfa..81409d401 100644 --- a/examples/commands/main.rs +++ b/examples/commands/main.rs @@ -37,12 +37,12 @@ fn window_label(window: Window) { #[command] async fn async_simple_command(the_argument: String) { - println!("{}", the_argument); + println!("{the_argument}"); } #[command(rename_all = "snake_case")] async fn async_simple_command_snake(the_argument: String) { - println!("{}", the_argument); + println!("{the_argument}"); } #[command] @@ -57,7 +57,7 @@ async fn async_stateful_command( #[command(async)] fn future_simple_command(the_argument: String) -> impl std::future::Future { - println!("{}", the_argument); + println!("{the_argument}"); std::future::ready(()) } @@ -65,7 +65,7 @@ fn future_simple_command(the_argument: String) -> impl std::future::Future impl std::future::Future { - println!("{}", the_argument); + println!("{the_argument}"); std::future::ready(the_argument) } @@ -73,7 +73,7 @@ fn future_simple_command_with_return( fn future_simple_command_with_result( the_argument: String, ) -> impl std::future::Future> { - println!("{}", the_argument); + println!("{the_argument}"); std::future::ready(Ok(the_argument)) } @@ -93,7 +93,7 @@ fn force_async_with_result(the_argument: &str) -> Result<&str, MyError> { #[command(async, rename_all = "snake_case")] fn future_simple_command_snake(the_argument: String) -> impl std::future::Future { - println!("{}", the_argument); + println!("{the_argument}"); std::future::ready(()) } @@ -101,7 +101,7 @@ fn future_simple_command_snake(the_argument: String) -> impl std::future::Future fn future_simple_command_with_return_snake( the_argument: String, ) -> impl std::future::Future { - println!("{}", the_argument); + println!("{the_argument}"); std::future::ready(the_argument) } @@ -109,7 +109,7 @@ fn future_simple_command_with_return_snake( fn future_simple_command_with_result_snake( the_argument: String, ) -> impl std::future::Future> { - println!("{}", the_argument); + println!("{the_argument}"); std::future::ready(Ok(the_argument)) } @@ -129,7 +129,7 @@ fn force_async_with_result_snake(the_argument: &str) -> Result<&str, MyError> { #[command] fn simple_command_with_result(the_argument: String) -> Result { - println!("{}", the_argument); + println!("{the_argument}"); (!the_argument.is_empty()) .then(|| the_argument) .ok_or(MyError::FooError) @@ -148,7 +148,7 @@ fn stateful_command_with_result( #[command(rename_all = "snake_case")] fn simple_command_with_result_snake(the_argument: String) -> Result { - println!("{}", the_argument); + println!("{the_argument}"); (!the_argument.is_empty()) .then(|| the_argument) .ok_or(MyError::FooError) @@ -167,7 +167,7 @@ fn stateful_command_with_result_snake( #[command] async fn async_simple_command_with_result(the_argument: String) -> Result { - println!("{}", the_argument); + println!("{the_argument}"); Ok(the_argument) } @@ -195,7 +195,7 @@ struct Person<'a> { #[command] fn command_arguments_struct(Person { name, age }: Person<'_>) { - println!("received person struct with name: {} | age: {}", name, age) + println!("received person struct with name: {name} | age: {age}") } #[derive(Deserialize)] @@ -203,7 +203,7 @@ struct InlinePerson<'a>(&'a str, u8); #[command] fn command_arguments_tuple_struct(InlinePerson(name, age): InlinePerson<'_>) { - println!("received person tuple with name: {} | age: {}", name, age) + println!("received person tuple with name: {name} | age: {age}") } #[command] diff --git a/examples/multiwindow/main.rs b/examples/multiwindow/main.rs index ae3a09ac5..3b5c98c7f 100644 --- a/examples/multiwindow/main.rs +++ b/examples/multiwindow/main.rs @@ -14,7 +14,7 @@ fn main() { .on_page_load(|window, _payload| { let label = window.label().to_string(); window.listen("clicked".to_string(), move |_payload| { - println!("got 'clicked' event on window '{}'", label); + println!("got 'clicked' event on window '{label}'"); }); }) .setup(|app| { diff --git a/examples/parent-window/main.rs b/examples/parent-window/main.rs index 5cd0e7012..835f7a43f 100644 --- a/examples/parent-window/main.rs +++ b/examples/parent-window/main.rs @@ -28,7 +28,7 @@ fn main() { .on_page_load(|window, _payload| { let label = window.label().to_string(); window.listen("clicked".to_string(), move |_payload| { - println!("got 'clicked' event on window '{}'", label); + println!("got 'clicked' event on window '{label}'"); }); }) .invoke_handler(tauri::generate_handler![create_child_window]) diff --git a/examples/streaming/main.rs b/examples/streaming/main.rs index 4dc479fea..56e72d046 100644 --- a/examples/streaming/main.rs +++ b/examples/streaming/main.rs @@ -23,7 +23,7 @@ fn main() { if !video_file.exists() { // Downloading with curl this saves us from adding // a Rust HTTP client dependency. - println!("Downloading {}", video_url); + println!("Downloading {video_url}"); let status = Command::new("curl") .arg("-L") .arg("-o") diff --git a/tooling/bundler/src/bundle/linux/debian.rs b/tooling/bundler/src/bundle/linux/debian.rs index 826a79f8b..8c8b43684 100644 --- a/tooling/bundler/src/bundle/linux/debian.rs +++ b/tooling/bundler/src/bundle/linux/debian.rs @@ -117,7 +117,7 @@ pub fn generate_data( for bin in settings.binaries() { let bin_path = settings.binary_path(bin); - common::copy_file(&bin_path, &bin_dir.join(bin.name())) + common::copy_file(&bin_path, bin_dir.join(bin.name())) .with_context(|| format!("Failed to copy binary from {:?}", bin_path))?; } diff --git a/tooling/bundler/src/bundle/path_utils.rs b/tooling/bundler/src/bundle/path_utils.rs index efde257c2..f3c550464 100644 --- a/tooling/bundler/src/bundle/path_utils.rs +++ b/tooling/bundler/src/bundle/path_utils.rs @@ -206,7 +206,10 @@ where let mut work = true; while work { - result_copy = copy_file(&file, &path, &file_options); + #[allow(clippy::needless_borrow)] + { + result_copy = copy_file(&file, &path, &file_options); + } match result_copy { Ok(val) => { result += val; diff --git a/tooling/bundler/src/bundle/settings.rs b/tooling/bundler/src/bundle/settings.rs index 4be02fd93..3aff75adb 100644 --- a/tooling/bundler/src/bundle/settings.rs +++ b/tooling/bundler/src/bundle/settings.rs @@ -655,7 +655,7 @@ impl Settings { .to_string_lossy() .replace(&format!("-{}", self.target), ""), ); - common::copy_file(&src, &dest)?; + common::copy_file(&src, dest)?; } Ok(()) } @@ -665,7 +665,7 @@ impl Settings { for src in self.resource_files() { let src = src?; let dest = path.join(tauri_utils::resources::resource_relpath(&src)); - common::copy_file(&src, &dest)?; + common::copy_file(&src, dest)?; } Ok(()) } diff --git a/tooling/cli/Cargo.lock b/tooling/cli/Cargo.lock index c4a67289f..e71d5e847 100644 --- a/tooling/cli/Cargo.lock +++ b/tooling/cli/Cargo.lock @@ -3435,9 +3435,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.5.9" +version = "0.5.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7" +checksum = "1333c76748e868a4d9d1017b5ab53171dfd095f70c712fdb4653a406547f598f" dependencies = [ "serde", ] diff --git a/tooling/cli/src/build.rs b/tooling/cli/src/build.rs index 24970604d..9a67d8b6f 100644 --- a/tooling/cli/src/build.rs +++ b/tooling/cli/src/build.rs @@ -185,8 +185,7 @@ pub fn command(mut options: Options) -> Result<()> { } None => { return Err(anyhow::anyhow!(format!( - "Unsupported bundle format: {}", - name + "Unsupported bundle format: {name}" ))); } } @@ -349,7 +348,7 @@ fn run_hook(name: &str, hook: HookCommand, interface: &AppInterface, debug: bool .current_dir(cwd) .envs(env) .piped() - .with_context(|| format!("failed to run `{}` with `sh -c`", script))?; + .with_context(|| format!("failed to run `{script}` with `sh -c`"))?; if !status.success() { bail!( @@ -384,9 +383,9 @@ mod pkgconfig_utils { pub fn get_appindicator_library_path() -> PathBuf { match get_library_path("ayatana-appindicator3-0.1") { - Some(p) => format!("{}/libayatana-appindicator3.so.1", p).into(), + Some(p) => format!("{p}/libayatana-appindicator3.so.1").into(), None => match get_library_path("appindicator3-0.1") { - Some(p) => format!("{}/libappindicator3.so.1", p).into(), + Some(p) => format!("{p}/libappindicator3.so.1").into(), None => panic!("Can't detect any appindicator library"), }, } diff --git a/tooling/cli/src/dev.rs b/tooling/cli/src/dev.rs index 4efa21281..0c9190a02 100644 --- a/tooling/cli/src/dev.rs +++ b/tooling/cli/src/dev.rs @@ -162,7 +162,7 @@ fn command_internal(mut options: Options) -> Result<()> { command.stderr(os_pipe::dup_stderr()?); let child = SharedChild::spawn(&mut command) - .unwrap_or_else(|_| panic!("failed to run `{}`", before_dev)); + .unwrap_or_else(|_| panic!("failed to run `{before_dev}`")); let child = Arc::new(child); let child_ = child.clone(); @@ -239,8 +239,7 @@ fn command_internal(mut options: Options) -> Result<()> { options.config = Some(serde_json::to_string(&c).unwrap()); } else { options.config = Some(format!( - r#"{{ "build": {{ "devPath": "{}" }} }}"#, - SERVER_URL + r#"{{ "build": {{ "devPath": "{SERVER_URL}" }} }}"# )) } } diff --git a/tooling/cli/src/helpers/updater_signature.rs b/tooling/cli/src/helpers/updater_signature.rs index 800e4e6ff..6b8609214 100644 --- a/tooling/cli/src/helpers/updater_signature.rs +++ b/tooling/cli/src/helpers/updater_signature.rs @@ -35,8 +35,8 @@ pub fn generate_key(password: Option) -> crate::Result { let pk_box_str = pk.to_box().unwrap().to_string(); let sk_box_str = sk.to_box(None).unwrap().to_string(); - let encoded_pk = encode(&pk_box_str); - let encoded_sk = encode(&sk_box_str); + let encoded_pk = encode(pk_box_str); + let encoded_sk = encode(sk_box_str); Ok(KeyPair { pk: encoded_pk, @@ -46,7 +46,7 @@ pub fn generate_key(password: Option) -> crate::Result { /// Transform a base64 String to readable string for the main signer pub fn decode_key(base64_key: String) -> crate::Result { - let decoded_str = &decode(&base64_key)?[..]; + let decoded_str = &decode(base64_key)?[..]; Ok(String::from(str::from_utf8(decoded_str)?)) } @@ -81,11 +81,11 @@ where } let mut sk_writer = create_file(sk_path)?; - write!(sk_writer, "{:}", key)?; + write!(sk_writer, "{key:}")?; sk_writer.flush()?; let mut pk_writer = create_file(pk_path)?; - write!(pk_writer, "{:}", pubkey)?; + write!(pk_writer, "{pubkey:}")?; pk_writer.flush()?; Ok((fs::canonicalize(sk_path)?, fs::canonicalize(pk_path)?)) @@ -128,7 +128,7 @@ where Some("signature from tauri secret key"), )?; - let encoded_signature = encode(&signature_box.to_string()); + let encoded_signature = encode(signature_box.to_string()); signature_box_writer.write_all(encoded_signature.as_bytes())?; signature_box_writer.flush()?; Ok((fs::canonicalize(&signature_path)?, signature_box)) diff --git a/tooling/cli/src/icon.rs b/tooling/cli/src/icon.rs index 76a1530bc..25a6262bb 100644 --- a/tooling/cli/src/icon.rs +++ b/tooling/cli/src/icon.rs @@ -76,7 +76,7 @@ fn appx(source: &DynamicImage, out_dir: &Path) -> Result<()> { resize_and_save_png(source, 50, &out_dir.join("StoreLogo.png"))?; for size in [30, 44, 71, 89, 107, 142, 150, 284, 310] { - let file_name = format!("Square{}x{}Logo.png", size, size); + let file_name = format!("Square{size}x{size}Logo.png"); log::info!(action = "Appx"; "Creating {}", file_name); resize_and_save_png(source, size, &out_dir.join(&file_name))?; @@ -108,7 +108,7 @@ fn icns(source: &DynamicImage, out_dir: &Path) -> Result<()> { &image, IconType::from_ostype(entry.ostype.parse().unwrap()).unwrap(), ) - .with_context(|| format!("Can't add {} to Icns Family", name))?; + .with_context(|| format!("Can't add {name} to Icns Family"))?; } let mut out_file = BufWriter::new(File::create(out_dir.join("icon.icns"))?); @@ -159,7 +159,7 @@ fn png(source: &DynamicImage, out_dir: &Path) -> Result<()> { let file_name = match size { 256 => "128x128@2x.png".to_string(), 512 => "icon.png".to_string(), - _ => format!("{}x{}.png", size, size), + _ => format!("{size}x{size}.png"), }; log::info!(action = "PNG"; "Creating {}", file_name); diff --git a/tooling/cli/src/info.rs b/tooling/cli/src/info.rs index 0091167c1..37edc7224 100644 --- a/tooling/cli/src/info.rs +++ b/tooling/cli/src/info.rs @@ -128,7 +128,7 @@ pub(crate) fn cli_upstream_version() -> Result { } fn crate_latest_version(name: &str) -> Option { - let url = format!("https://docs.rs/crate/{}/", name); + let url = format!("https://docs.rs/crate/{name}/"); match ureq::get(&url).call() { Ok(response) => match (response.status(), response.header("location")) { (302, Some(location)) => Some(location.replace(&url, "")), @@ -431,7 +431,7 @@ fn crate_version( crate_lock_package.version.clone() }; ( - format!("{} (no manifest)", version_string), + format!("{version_string} (no manifest)"), vec![crate_lock_package.version.clone()], ) } @@ -450,21 +450,21 @@ fn crate_version( v } else if let Some(p) = p.path { let manifest_path = tauri_dir.join(&p).join("Cargo.toml"); - let v = match read_to_string(&manifest_path) + let v = match read_to_string(manifest_path) .map_err(|_| ()) .and_then(|m| toml::from_str::(&m).map_err(|_| ())) { Ok(manifest) => manifest.package.version, Err(_) => "unknown version".to_string(), }; - format!("path:{:?} [{}]", p, v) + format!("path:{p:?} [{v}]") } else if let Some(g) = p.git { is_git = true; - let mut v = format!("git:{}", g); + let mut v = format!("git:{g}"); if let Some(branch) = p.branch { - let _ = write!(v, "&branch={}", branch); + let _ = write!(v, "&branch={branch}"); } else if let Some(rev) = p.rev { - let _ = write!(v, "#{}", rev); + let _ = write!(v, "#{rev}"); } v } else { @@ -505,7 +505,7 @@ fn crate_version( (Some(version), Some(target_version)) => { let target_version = semver::Version::parse(&target_version).unwrap(); if version < target_version { - Some(format!(" (outdated, latest: {})", target_version)) + Some(format!(" (outdated, latest: {target_version})")) } else { None } diff --git a/tooling/cli/src/interface/rust.rs b/tooling/cli/src/interface/rust.rs index 2fd9dee83..41c6f442a 100644 --- a/tooling/cli/src/interface/rust.rs +++ b/tooling/cli/src/interface/rust.rs @@ -538,8 +538,7 @@ impl MaybeWorkspace { MaybeWorkspace::Defined(value) => Ok(value), MaybeWorkspace::Workspace(TomlWorkspaceField { workspace: true }) => { get_ws_field().context(format!( - "error inheriting `{}` from workspace root manifest's `workspace.package.{}`", - label, label + "error inheriting `{label}` from workspace root manifest's `workspace.package.{label}`" )) } MaybeWorkspace::Workspace(TomlWorkspaceField { workspace: false }) => Err(anyhow::anyhow!( @@ -674,7 +673,7 @@ impl AppSettings for RustAppSettings { } .into(); - Ok(out_dir.join(bin_name).with_extension(&binary_extension)) + Ok(out_dir.join(bin_name).with_extension(binary_extension)) } fn get_binaries(&self, config: &Config, target: &str) -> crate::Result> { diff --git a/tooling/cli/src/interface/rust/cargo_config.rs b/tooling/cli/src/interface/rust/cargo_config.rs index b55389bff..8adca17dd 100644 --- a/tooling/cli/src/interface/rust/cargo_config.rs +++ b/tooling/cli/src/interface/rust/cargo_config.rs @@ -103,7 +103,7 @@ fn get_file_path( warn: bool, ) -> Result> { let possible = dir.join(filename_without_extension); - let possible_with_extension = dir.join(format!("{}.toml", filename_without_extension)); + let possible_with_extension = dir.join(format!("{filename_without_extension}.toml")); if possible.exists() { if warn && possible_with_extension.exists() { diff --git a/tooling/cli/src/interface/rust/desktop.rs b/tooling/cli/src/interface/rust/desktop.rs index 668edf5f1..63e1c097a 100644 --- a/tooling/cli/src/interface/rust/desktop.rs +++ b/tooling/cli/src/interface/rust/desktop.rs @@ -109,10 +109,10 @@ pub fn build( let triple_out_dir = app_settings .out_dir(Some(triple.into()), options.debug) - .with_context(|| format!("failed to get {} out dir", triple))?; + .with_context(|| format!("failed to get {triple} out dir"))?; build_production_app(options, available_targets, config_features.clone()) - .with_context(|| format!("failed to build {} binary", triple))?; + .with_context(|| format!("failed to build {triple} binary"))?; lipo_cmd.arg(triple_out_dir.join(bin_name)); } @@ -120,8 +120,7 @@ pub fn build( let lipo_status = lipo_cmd.output_ok()?.status; if !lipo_status.success() { return Err(anyhow::anyhow!(format!( - "Result of `lipo` command was unsuccessful: {}. (Is `lipo` installed?)", - lipo_status + "Result of `lipo` command was unsuccessful: {lipo_status}. (Is `lipo` installed?)" ))); } } else { @@ -288,7 +287,7 @@ fn build_command( args.push(target); } - let mut build_cmd = Command::new(&runner); + let mut build_cmd = Command::new(runner); build_cmd.arg("build"); build_cmd.args(args); @@ -341,7 +340,7 @@ fn rename_app(bin_path: &Path, product_name: Option<&str>) -> crate::Result = self .tauri_features .iter() - .map(|f| format!("tauri/{}", f)) + .map(|f| format!("tauri/{f}")) .collect(); let manifest_features = self.features(); @@ -86,7 +86,7 @@ fn read_manifest(manifest_path: &Path) -> crate::Result { let mut manifest_str = String::new(); let mut manifest_file = File::open(manifest_path) - .with_context(|| format!("failed to open `{:?}` file", manifest_path))?; + .with_context(|| format!("failed to open `{manifest_path:?}` file"))?; manifest_file.read_to_string(&mut manifest_str)?; let manifest: Document = manifest_str diff --git a/tooling/cli/src/lib.rs b/tooling/cli/src/lib.rs index 1859d0d8f..05939c0c3 100644 --- a/tooling/cli/src/lib.rs +++ b/tooling/cli/src/lib.rs @@ -156,7 +156,7 @@ where .try_init(); if let Err(err) = init_res { - eprintln!("Failed to attach logger: {}", err); + eprintln!("Failed to attach logger: {err}"); } match cli.command { @@ -204,14 +204,14 @@ impl CommandExt for Command { self.stdout(os_pipe::dup_stdout()?); self.stderr(os_pipe::dup_stderr()?); let program = self.get_program().to_string_lossy().into_owned(); - debug!(action = "Running"; "Command `{} {}`", program, self.get_args().map(|arg| arg.to_string_lossy()).fold(String::new(), |acc, arg| format!("{} {}", acc, arg))); + debug!(action = "Running"; "Command `{} {}`", program, self.get_args().map(|arg| arg.to_string_lossy()).fold(String::new(), |acc, arg| format!("{acc} {arg}"))); self.status().map_err(Into::into) } fn output_ok(&mut self) -> crate::Result { let program = self.get_program().to_string_lossy().into_owned(); - debug!(action = "Running"; "Command `{} {}`", program, self.get_args().map(|arg| arg.to_string_lossy()).fold(String::new(), |acc, arg| format!("{} {}", acc, arg))); + debug!(action = "Running"; "Command `{} {}`", program, self.get_args().map(|arg| arg.to_string_lossy()).fold(String::new(), |acc, arg| format!("{acc} {arg}"))); self.stdout(Stdio::piped()); self.stderr(Stdio::piped()); diff --git a/tooling/cli/src/plugin/init.rs b/tooling/cli/src/plugin/init.rs index 75bd99477..62eafcc02 100644 --- a/tooling/cli/src/plugin/init.rs +++ b/tooling/cli/src/plugin/init.rs @@ -56,7 +56,7 @@ impl Options { pub fn command(mut options: Options) -> Result<()> { options.load(); - let template_target_path = PathBuf::from(options.directory).join(&format!( + let template_target_path = PathBuf::from(options.directory).join(format!( "tauri-plugin-{}", AsKebabCase(&options.plugin_name) ));