Skip to content

Commit 0150207

Browse files
committed
chore: fix clippy warnings
1 parent a02c6c4 commit 0150207

File tree

54 files changed

+163
-182
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+163
-182
lines changed

core/config-schema/build.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub fn main() -> Result<(), Box<dyn Error>> {
1818
crate_dir.join("../../tooling/cli/schema.json"),
1919
] {
2020
let mut schema_file = BufWriter::new(File::create(&file)?);
21-
write!(schema_file, "{}", schema_str)?;
21+
write!(schema_file, "{schema_str}")?;
2222
}
2323

2424
Ok(())

core/tauri-build/src/codegen/context.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ impl CodegenContext {
8686
pub fn build(self) -> PathBuf {
8787
match self.try_build() {
8888
Ok(out) => out,
89-
Err(error) => panic!("Error found during Codegen::build: {}", error),
89+
Err(error) => panic!("Error found during Codegen::build: {error}"),
9090
}
9191
}
9292

@@ -161,7 +161,7 @@ impl CodegenContext {
161161
)
162162
})?;
163163

164-
writeln!(file, "{}", code).with_context(|| {
164+
writeln!(file, "{code}").with_context(|| {
165165
format!(
166166
"Unable to write tokenstream to out file during tauri-build {}",
167167
out.display()

core/tauri-build/src/lib.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ fn copy_file(from: impl AsRef<Path>, to: impl AsRef<Path>) -> Result<()> {
3535
Ok(())
3636
}
3737

38-
fn copy_binaries<'a>(
39-
binaries: ResourcePaths<'a>,
38+
fn copy_binaries(
39+
binaries: ResourcePaths,
4040
target_triple: &str,
4141
path: &Path,
4242
package_name: Option<&String>,
@@ -48,7 +48,7 @@ fn copy_binaries<'a>(
4848
.file_name()
4949
.expect("failed to extract external binary filename")
5050
.to_string_lossy()
51-
.replace(&format!("-{}", target_triple), "");
51+
.replace(&format!("-{target_triple}"), "");
5252

5353
if package_name.map_or(false, |n| n == &file_name) {
5454
return Err(anyhow::anyhow!(
@@ -90,7 +90,7 @@ fn has_feature(feature: &str) -> bool {
9090
// `alias` must be a snake case string.
9191
fn cfg_alias(alias: &str, has_feature: bool) {
9292
if has_feature {
93-
println!("cargo:rustc-cfg={}", alias);
93+
println!("cargo:rustc-cfg={alias}");
9494
}
9595
}
9696

@@ -227,8 +227,8 @@ impl Attributes {
227227
/// This is typically desirable when running inside a build script; see [`try_build`] for no panics.
228228
pub fn build() {
229229
if let Err(error) = try_build(Attributes::default()) {
230-
let error = format!("{:#}", error);
231-
println!("{}", error);
230+
let error = format!("{error:#}");
231+
println!("{error}");
232232
if error.starts_with("unknown field") {
233233
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. ");
234234
println!(

core/tauri-codegen/src/context.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ pub fn context_codegen(data: ContextData) -> Result<TokenStream, EmbeddedAssetsE
141141
} else if target.contains("apple-ios") {
142142
Target::Ios
143143
} else {
144-
panic!("unknown codegen target {}", target);
144+
panic!("unknown codegen target {target}");
145145
}
146146
} else if cfg!(target_os = "linux") {
147147
Target::Linux
@@ -371,8 +371,7 @@ pub fn context_codegen(data: ContextData) -> Result<TokenStream, EmbeddedAssetsE
371371
let dir = config_parent.join(dir);
372372
if !dir.exists() {
373373
panic!(
374-
"The isolation application path is set to `{:?}` but it does not exist",
375-
dir
374+
"The isolation application path is set to `{dir:?}` but it does not exist"
376375
)
377376
}
378377

core/tauri-codegen/src/embedded_assets.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -343,14 +343,14 @@ impl EmbeddedAssets {
343343

344344
let mut hex = String::with_capacity(2 * bytes.len());
345345
for b in bytes {
346-
write!(hex, "{:02x}", b).map_err(EmbeddedAssetsError::Hex)?;
346+
write!(hex, "{b:02x}").map_err(EmbeddedAssetsError::Hex)?;
347347
}
348348
hex
349349
};
350350

351351
// use the content hash to determine filename, keep extensions that exist
352352
let out_path = if let Some(ext) = path.extension().and_then(|e| e.to_str()) {
353-
out_dir.join(format!("{}.{}", hash, ext))
353+
out_dir.join(format!("{hash}.{ext}"))
354354
} else {
355355
out_dir.join(hash)
356356
};

core/tauri-runtime-wry/build.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// `alias` must be a snake case string.
77
fn alias(alias: &str, has_feature: bool) {
88
if has_feature {
9-
println!("cargo:rustc-cfg={}", alias);
9+
println!("cargo:rustc-cfg={alias}");
1010
}
1111
}
1212

core/tauri-runtime/build.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// `alias` must be a snake case string.
77
fn alias(alias: &str, has_feature: bool) {
88
if has_feature {
9-
println!("cargo:rustc-cfg={}", alias);
9+
println!("cargo:rustc-cfg={alias}");
1010
}
1111
}
1212

core/tauri-utils/src/config.rs

+9-10
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ pub enum WindowUrl {
5555
impl fmt::Display for WindowUrl {
5656
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
5757
match self {
58-
Self::External(url) => write!(f, "{}", url),
58+
Self::External(url) => write!(f, "{url}"),
5959
Self::App(path) => write!(f, "{}", path.display()),
6060
}
6161
}
@@ -125,7 +125,7 @@ impl<'de> Deserialize<'de> for BundleType {
125125
"app" => Ok(Self::App),
126126
"dmg" => Ok(Self::Dmg),
127127
"updater" => Ok(Self::Updater),
128-
_ => Err(DeError::custom(format!("unknown bundle target '{}'", s))),
128+
_ => Err(DeError::custom(format!("unknown bundle target '{s}'"))),
129129
}
130130
}
131131
}
@@ -223,7 +223,7 @@ impl<'de> Deserialize<'de> for BundleTarget {
223223

224224
match BundleTargetInner::deserialize(deserializer)? {
225225
BundleTargetInner::All(s) if s.to_lowercase() == "all" => Ok(Self::All),
226-
BundleTargetInner::All(t) => Err(DeError::custom(format!("invalid bundle type {}", t))),
226+
BundleTargetInner::All(t) => Err(DeError::custom(format!("invalid bundle type {t}"))),
227227
BundleTargetInner::List(l) => Ok(Self::List(l)),
228228
BundleTargetInner::One(t) => Ok(Self::One(t)),
229229
}
@@ -994,7 +994,7 @@ impl CspDirectiveSources {
994994
/// Whether the given source is configured on this directive or not.
995995
pub fn contains(&self, source: &str) -> bool {
996996
match self {
997-
Self::Inline(s) => s.contains(&format!("{} ", source)) || s.contains(&format!(" {}", source)),
997+
Self::Inline(s) => s.contains(&format!("{source} ")) || s.contains(&format!(" {source}")),
998998
Self::List(l) => l.contains(&source.into()),
999999
}
10001000
}
@@ -1060,7 +1060,7 @@ impl From<Csp> for HashMap<String, CspDirectiveSources> {
10601060
impl Display for Csp {
10611061
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
10621062
match self {
1063-
Self::Policy(s) => write!(f, "{}", s),
1063+
Self::Policy(s) => write!(f, "{s}"),
10641064
Self::DirectiveMap(m) => {
10651065
let len = m.len();
10661066
let mut i = 0;
@@ -2365,8 +2365,7 @@ impl<'de> Deserialize<'de> for WindowsUpdateInstallMode {
23652365
"quiet" => Ok(Self::Quiet),
23662366
"passive" => Ok(Self::Passive),
23672367
_ => Err(DeError::custom(format!(
2368-
"unknown update install mode '{}'",
2369-
s
2368+
"unknown update install mode '{s}'"
23702369
))),
23712370
}
23722371
}
@@ -2510,7 +2509,7 @@ pub enum AppUrl {
25102509
impl std::fmt::Display for AppUrl {
25112510
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
25122511
match self {
2513-
Self::Url(url) => write!(f, "{}", url),
2512+
Self::Url(url) => write!(f, "{url}"),
25142513
Self::Files(files) => write!(f, "{}", serde_json::to_string(files).unwrap()),
25152514
}
25162515
}
@@ -2649,9 +2648,9 @@ impl<'d> serde::Deserialize<'d> for PackageVersion {
26492648
let path = PathBuf::from(value);
26502649
if path.exists() {
26512650
let json_str = read_to_string(&path)
2652-
.map_err(|e| DeError::custom(format!("failed to read version JSON file: {}", e)))?;
2651+
.map_err(|e| DeError::custom(format!("failed to read version JSON file: {e}")))?;
26532652
let package_json: serde_json::Value = serde_json::from_str(&json_str)
2654-
.map_err(|e| DeError::custom(format!("failed to read version JSON file: {}", e)))?;
2653+
.map_err(|e| DeError::custom(format!("failed to read version JSON file: {e}")))?;
26552654
if let Some(obj) = package_json.as_object() {
26562655
let version = obj
26572656
.get("version")

core/tauri-utils/src/html.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ fn serialize_node_ref_internal<S: Serializer>(
3737
traversal_scope: TraversalScope,
3838
) -> crate::Result<()> {
3939
match (traversal_scope, node.data()) {
40-
(ref scope, &NodeData::Element(ref element)) => {
40+
(ref scope, NodeData::Element(element)) => {
4141
if *scope == TraversalScope::IncludeNode {
4242
let attrs = element.attributes.borrow();
4343

@@ -82,16 +82,16 @@ fn serialize_node_ref_internal<S: Serializer>(
8282

8383
(TraversalScope::ChildrenOnly(_), _) => Ok(()),
8484

85-
(TraversalScope::IncludeNode, &NodeData::Doctype(ref doctype)) => {
85+
(TraversalScope::IncludeNode, NodeData::Doctype(doctype)) => {
8686
serializer.write_doctype(&doctype.name).map_err(Into::into)
8787
}
88-
(TraversalScope::IncludeNode, &NodeData::Text(ref text)) => {
88+
(TraversalScope::IncludeNode, NodeData::Text(text)) => {
8989
serializer.write_text(&text.borrow()).map_err(Into::into)
9090
}
91-
(TraversalScope::IncludeNode, &NodeData::Comment(ref text)) => {
91+
(TraversalScope::IncludeNode, NodeData::Comment(text)) => {
9292
serializer.write_comment(&text.borrow()).map_err(Into::into)
9393
}
94-
(TraversalScope::IncludeNode, &NodeData::ProcessingInstruction(ref contents)) => {
94+
(TraversalScope::IncludeNode, NodeData::ProcessingInstruction(contents)) => {
9595
let contents = contents.borrow();
9696
serializer
9797
.write_processing_instruction(&contents.0, &contents.1)

core/tauri-utils/src/mime_type.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ impl std::fmt::Display for MimeType {
3939
MimeType::Svg => "image/svg+xml",
4040
MimeType::Mp4 => "video/mp4",
4141
};
42-
write!(f, "{}", mime)
42+
write!(f, "{mime}")
4343
}
4444
}
4545

core/tauri-utils/src/platform.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,10 @@ pub fn target_triple() -> crate::Result<String> {
133133
return Err(crate::Error::Environment);
134134
};
135135

136-
format!("{}-{}", os, env)
136+
format!("{os}-{env}")
137137
};
138138

139-
Ok(format!("{}-{}", arch, os))
139+
Ok(format!("{arch}-{os}"))
140140
}
141141

142142
/// Computes the resource directory of the current environment.
@@ -157,8 +157,8 @@ pub fn resource_dir(package_info: &PackageInfo, env: &Env) -> crate::Result<Path
157157
let exe_dir = exe.parent().expect("failed to get exe directory");
158158
let curr_dir = exe_dir.display().to_string();
159159

160-
if curr_dir.ends_with(format!("{S}target{S}debug", S = MAIN_SEPARATOR).as_str())
161-
|| curr_dir.ends_with(format!("{S}target{S}release", S = MAIN_SEPARATOR).as_str())
160+
if curr_dir.ends_with(format!("{MAIN_SEPARATOR}target{MAIN_SEPARATOR}debug").as_str())
161+
|| curr_dir.ends_with(format!("{MAIN_SEPARATOR}target{MAIN_SEPARATOR}release").as_str())
162162
|| cfg!(target_os = "windows")
163163
{
164164
// running from the out dir or windows

core/tauri/build.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ fn has_feature(feature: &str) -> bool {
3131
// `alias` must be a snake case string.
3232
fn alias(alias: &str, has_feature: bool) {
3333
if has_feature {
34-
println!("cargo:rustc-cfg={}", alias);
34+
println!("cargo:rustc-cfg={alias}");
3535
}
3636
}
3737

@@ -137,8 +137,8 @@ fn main() {
137137
let checked_features_out_path =
138138
Path::new(&std::env::var("OUT_DIR").unwrap()).join("checked_features");
139139
std::fs::write(
140-
&checked_features_out_path,
141-
&CHECKED_FEATURES.get().unwrap().lock().unwrap().join(","),
140+
checked_features_out_path,
141+
CHECKED_FEATURES.get().unwrap().lock().unwrap().join(","),
142142
)
143143
.expect("failed to write checked_features file");
144144
}
@@ -153,14 +153,14 @@ fn main() {
153153
//
154154
// Note that both `module` and `apis` strings must be written in kebab case.
155155
fn alias_module(module: &str, apis: &[&str], api_all: bool) {
156-
let all_feature_name = format!("{}-all", module);
156+
let all_feature_name = format!("{module}-all");
157157
let all = has_feature(&all_feature_name) || api_all;
158158
alias(&all_feature_name.to_snake_case(), all);
159159

160160
let mut any = all;
161161

162162
for api in apis {
163-
let has = has_feature(&format!("{}-{}", module, api)) || all;
163+
let has = has_feature(&format!("{module}-{api}")) || all;
164164
alias(
165165
&format!("{}_{}", AsSnakeCase(module), AsSnakeCase(api)),
166166
has,

core/tauri/src/api/dir.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ mod test {
226226
fn check_test_dir() {
227227
// create a callback closure that takes in a TempDir type and prints it.
228228
let callback = |td: &tempfile::TempDir| {
229-
println!("{:?}", td);
229+
println!("{td:?}");
230230
};
231231

232232
// execute the with_temp_dir function on the callback

core/tauri/src/api/file/extract.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ impl<'a, R: std::fmt::Debug + Read + Seek> std::fmt::Debug for Extract<'a, R> {
150150
impl<'a, R: Read + Seek> Extract<'a, R> {
151151
/// Create archive from reader.
152152
pub fn from_cursor(mut reader: R, archive_format: ArchiveFormat) -> Extract<'a, R> {
153-
if reader.seek(io::SeekFrom::Start(0)).is_err() {
153+
if reader.rewind().is_err() {
154154
#[cfg(debug_assertions)]
155155
eprintln!("Could not seek to start of the file");
156156
}

core/tauri/src/api/http.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ impl TryFrom<FilePart> for Vec<u8> {
368368
type Error = crate::api::Error;
369369
fn try_from(file: FilePart) -> crate::api::Result<Self> {
370370
let bytes = match file {
371-
FilePart::Path(path) => std::fs::read(&path)?,
371+
FilePart::Path(path) => std::fs::read(path)?,
372372
FilePart::Contents(bytes) => bytes,
373373
};
374374
Ok(bytes)
@@ -441,8 +441,7 @@ impl<'de> Deserialize<'de> for HeaderMap {
441441
headers.insert(key, value);
442442
} else {
443443
return Err(serde::de::Error::custom(format!(
444-
"invalid header `{}` `{}`",
445-
key, value
444+
"invalid header `{key}` `{value}`"
446445
)));
447446
}
448447
}

core/tauri/src/api/ipc.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -242,22 +242,22 @@ mod test {
242242
}
243243

244244
let raw_str = "T".repeat(MIN_JSON_PARSE_LEN);
245-
assert_eq!(serialize_js(&raw_str).unwrap(), format!("\"{}\"", raw_str));
245+
assert_eq!(serialize_js(&raw_str).unwrap(), format!("\"{raw_str}\""));
246246

247247
assert_eq!(
248248
serialize_js(&JsonObj {
249249
value: raw_str.clone()
250250
})
251251
.unwrap(),
252-
format!("JSON.parse('{{\"value\":\"{}\"}}')", raw_str)
252+
format!("JSON.parse('{{\"value\":\"{raw_str}\"}}')")
253253
);
254254

255255
assert_eq!(
256256
serialize_js(&JsonObj {
257-
value: format!("\"{}\"", raw_str)
257+
value: format!("\"{raw_str}\"")
258258
})
259259
.unwrap(),
260-
format!("JSON.parse('{{\"value\":\"\\\\\"{}\\\\\"\"}}')", raw_str)
260+
format!("JSON.parse('{{\"value\":\"\\\\\"{raw_str}\\\\\"\"}}')")
261261
);
262262

263263
let dangerous_json = RawValue::from_string(

core/tauri/src/api/shell.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,5 +112,5 @@ pub fn open<P: AsRef<str>>(
112112
) -> crate::api::Result<()> {
113113
scope
114114
.open(path.as_ref(), with)
115-
.map_err(|err| crate::api::Error::Shell(format!("failed to open: {}", err)))
115+
.map_err(|err| crate::api::Error::Shell(format!("failed to open: {err}")))
116116
}

core/tauri/src/app.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1290,8 +1290,7 @@ impl<R: Runtime> Builder<R> {
12901290
let type_name = std::any::type_name::<T>();
12911291
assert!(
12921292
self.state.set(state),
1293-
"state for type '{}' is already being managed",
1294-
type_name
1293+
"state for type '{type_name}' is already being managed"
12951294
);
12961295
self
12971296
}

core/tauri/src/endpoints.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,7 @@ pub(crate) fn handle<R: Runtime>(
238238
if let Some(unknown_variant_name) = s.next() {
239239
if unknown_variant_name == module {
240240
return resolver.reject(format!(
241-
"The `{}` module is not enabled. You must enable one of its APIs in the allowlist.",
242-
module
241+
"The `{module}` module is not enabled. You must enable one of its APIs in the allowlist."
243242
));
244243
} else if module == "Window" {
245244
return resolver.reject(window::into_allowlist_error(unknown_variant_name).to_string());

core/tauri/src/endpoints/event.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ impl Cmd {
138138
serde_json::to_string(&p)
139139
.map_err(|e| {
140140
#[cfg(debug_assertions)]
141-
eprintln!("{}", e);
141+
eprintln!("{e}");
142142
e
143143
})
144144
.ok()

0 commit comments

Comments
 (0)