Skip to content

Commit 3f836c4

Browse files
Clippy fix
1 parent a04eecd commit 3f836c4

File tree

13 files changed

+38
-53
lines changed

13 files changed

+38
-53
lines changed

tooling/bundler/src/bundle/category.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,7 @@ impl<'d> serde::de::Visitor<'d> for AppCategoryVisitor {
254254
match self.did_you_mean {
255255
Some(string) => write!(
256256
formatter,
257-
"a valid app category string (did you mean \"{}\"?)",
258-
string
257+
"a valid app category string (did you mean \"{string}\"?)"
259258
),
260259
None => write!(formatter, "a valid app category string"),
261260
}

tooling/bundler/src/bundle/common.rs

+7-13
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,12 @@ pub fn copy_file(from: impl AsRef<Path>, to: impl AsRef<Path>) -> crate::Result<
7272
let to = to.as_ref();
7373
if !from.exists() {
7474
return Err(crate::Error::GenericError(format!(
75-
"{:?} does not exist",
76-
from
75+
"{from:?} does not exist"
7776
)));
7877
}
7978
if !from.is_file() {
8079
return Err(crate::Error::GenericError(format!(
81-
"{:?} is not a file",
82-
from
80+
"{from:?} is not a file"
8381
)));
8482
}
8583
let dest_dir = to.parent().expect("No data in parent");
@@ -96,20 +94,17 @@ pub fn copy_file(from: impl AsRef<Path>, to: impl AsRef<Path>) -> crate::Result<
9694
pub fn copy_dir(from: &Path, to: &Path) -> crate::Result<()> {
9795
if !from.exists() {
9896
return Err(crate::Error::GenericError(format!(
99-
"{:?} does not exist",
100-
from
97+
"{from:?} does not exist"
10198
)));
10299
}
103100
if !from.is_dir() {
104101
return Err(crate::Error::GenericError(format!(
105-
"{:?} is not a Directory",
106-
from
102+
"{from:?} is not a Directory"
107103
)));
108104
}
109105
if to.exists() {
110106
return Err(crate::Error::GenericError(format!(
111-
"{:?} already exists",
112-
from
107+
"{from:?} already exists"
113108
)));
114109
}
115110
let parent = to.parent().expect("No data in parent");
@@ -154,7 +149,7 @@ impl CommandExt for Command {
154149

155150
fn output_ok(&mut self) -> crate::Result<Output> {
156151
let program = self.get_program().to_string_lossy().into_owned();
157-
debug!(action = "Running"; "Command `{} {}`", program, self.get_args().map(|arg| arg.to_string_lossy()).fold(String::new(), |acc, arg| format!("{} {}", acc, arg)));
152+
debug!(action = "Running"; "Command `{} {}`", program, self.get_args().map(|arg| arg.to_string_lossy()).fold(String::new(), |acc, arg| format!("{acc} {arg}")));
158153

159154
self.stdout(Stdio::piped());
160155
self.stderr(Stdio::piped());
@@ -208,8 +203,7 @@ impl CommandExt for Command {
208203
Ok(output)
209204
} else {
210205
Err(crate::Error::GenericError(format!(
211-
"failed to run {}",
212-
program
206+
"failed to run {program}"
213207
)))
214208
}
215209
}

tooling/bundler/src/bundle/linux/debian.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ pub fn bundle_project(settings: &Settings) -> crate::Result<Vec<PathBuf>> {
5454
settings.version_string(),
5555
arch
5656
);
57-
let package_name = format!("{}.deb", package_base_name);
57+
let package_name = format!("{package_base_name}.deb");
5858

5959
let base_dir = settings.project_out_directory().join("bundle/deb");
6060
let package_dir = base_dir.join(&package_base_name);
6161
if package_dir.exists() {
6262
fs::remove_dir_all(&package_dir)
63-
.with_context(|| format!("Failed to remove old {}", package_base_name))?;
63+
.with_context(|| format!("Failed to remove old {package_base_name}"))?;
6464
}
6565
let package_path = base_dir.join(&package_name);
6666

@@ -107,7 +107,7 @@ pub fn generate_data(
107107
for bin in settings.binaries() {
108108
let bin_path = settings.binary_path(bin);
109109
common::copy_file(&bin_path, bin_dir.join(bin.name()))
110-
.with_context(|| format!("Failed to copy binary from {:?}", bin_path))?;
110+
.with_context(|| format!("Failed to copy binary from {bin_path:?}"))?;
111111
}
112112

113113
copy_resource_files(settings, &data_dir).with_context(|| "Failed to copy resource files")?;
@@ -137,11 +137,11 @@ fn generate_control_file(
137137
let mut file = common::create_file(&dest_path)?;
138138
writeln!(file, "Package: {}", AsKebabCase(settings.product_name()))?;
139139
writeln!(file, "Version: {}", settings.version_string())?;
140-
writeln!(file, "Architecture: {}", arch)?;
140+
writeln!(file, "Architecture: {arch}")?;
141141
// Installed-Size must be divided by 1024, see https://www.debian.org/doc/debian-policy/ch-controlfields.html#installed-size
142142
writeln!(file, "Installed-Size: {}", total_dir_size(data_dir)? / 1024)?;
143143
let authors = settings.authors_comma_separated().unwrap_or_default();
144-
writeln!(file, "Maintainer: {}", authors)?;
144+
writeln!(file, "Maintainer: {authors}")?;
145145
if !settings.homepage_url().is_empty() {
146146
writeln!(file, "Homepage: {}", settings.homepage_url())?;
147147
}
@@ -157,13 +157,13 @@ fn generate_control_file(
157157
if long_description.is_empty() {
158158
long_description = "(none)";
159159
}
160-
writeln!(file, "Description: {}", short_description)?;
160+
writeln!(file, "Description: {short_description}")?;
161161
for line in long_description.lines() {
162162
let line = line.trim();
163163
if line.is_empty() {
164164
writeln!(file, " .")?;
165165
} else {
166-
writeln!(file, " {}", line)?;
166+
writeln!(file, " {line}")?;
167167
}
168168
}
169169
writeln!(file, "Priority: optional")?;
@@ -186,14 +186,14 @@ fn generate_md5sums(control_dir: &Path, data_dir: &Path) -> crate::Result<()> {
186186
let mut hash = md5::Context::new();
187187
io::copy(&mut file, &mut hash)?;
188188
for byte in hash.compute().iter() {
189-
write!(md5sums_file, "{:02x}", byte)?;
189+
write!(md5sums_file, "{byte:02x}")?;
190190
}
191191
let rel_path = path.strip_prefix(data_dir)?;
192192
let path_str = rel_path.to_str().ok_or_else(|| {
193-
let msg = format!("Non-UTF-8 path: {:?}", rel_path);
193+
let msg = format!("Non-UTF-8 path: {rel_path:?}");
194194
io::Error::new(io::ErrorKind::InvalidData, msg)
195195
})?;
196-
writeln!(md5sums_file, " {}", path_str)?;
196+
writeln!(md5sums_file, " {path_str}")?;
197197
}
198198
Ok(())
199199
}

tooling/bundler/src/bundle/linux/freedesktop.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ pub fn generate_desktop_file(
9494
data_dir: &Path,
9595
) -> crate::Result<(PathBuf, PathBuf)> {
9696
let bin_name = settings.main_binary_name();
97-
let desktop_file_name = format!("{}.desktop", bin_name);
97+
let desktop_file_name = format!("{bin_name}.desktop");
9898
let path = PathBuf::from("usr/share/applications").join(desktop_file_name);
9999
let dest_path = PathBuf::from("/").join(&path);
100100
let file_path = data_dir.join(&path);
@@ -109,8 +109,8 @@ pub fn generate_desktop_file(
109109
if !settings.short_description().is_empty() {
110110
writeln!(file, "Comment={}", settings.short_description())?;
111111
}
112-
writeln!(file, "Exec={}", bin_name)?;
113-
writeln!(file, "Icon={}", bin_name)?;
112+
writeln!(file, "Exec={bin_name}")?;
113+
writeln!(file, "Icon={bin_name}")?;
114114
writeln!(file, "Name={}", settings.product_name())?;
115115
writeln!(file, "Terminal=false")?;
116116
writeln!(file, "Type=Application")?;

tooling/bundler/src/bundle/linux/rpm.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ pub fn bundle_project(settings: &Settings) -> crate::Result<Vec<PathBuf>> {
3939
// (current limitation of rpm-rs)
4040
let desc = settings.short_description();
4141

42-
let package_base_name = format!("{}-{}-{}.{}", name, version, release, arch);
43-
let package_name = format!("{}.rpm", package_base_name);
42+
let package_base_name = format!("{name}-{version}-{release}.{arch}");
43+
let package_name = format!("{package_base_name}.rpm");
4444

4545
let base_dir = settings.project_out_directory().join("bundle/rpm");
4646
let package_dir = base_dir.join(&package_base_name);
4747
if package_dir.exists() {
4848
fs::remove_dir_all(&package_dir)
49-
.with_context(|| format!("Failed to remove old {}", package_base_name))?;
49+
.with_context(|| format!("Failed to remove old {package_base_name}"))?;
5050
}
5151
fs::create_dir_all(&package_dir)?;
5252
let package_path = base_dir.join(package_name);

tooling/bundler/src/bundle/path_utils.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ where
104104
let from = from.as_ref();
105105
if !from.exists() {
106106
if let Some(msg) = from.to_str() {
107-
let msg = format!("Path \"{}\" does not exist or you don't have access", msg);
107+
let msg = format!("Path \"{msg}\" does not exist or you don't have access");
108108
return Err(crate::Error::PathUtilError(msg));
109109
}
110110
return Err(crate::Error::PathUtilError(
@@ -114,7 +114,7 @@ where
114114

115115
if !from.is_file() {
116116
if let Some(msg) = from.to_str() {
117-
let msg = format!("Path \"{}\" is not a file!", msg);
117+
let msg = format!("Path \"{msg}\" is not a file!");
118118
return Err(crate::Error::PathUtilError(msg));
119119
}
120120
return Err(crate::Error::PathUtilError(
@@ -127,7 +127,7 @@ where
127127
}
128128

129129
if let Some(msg) = to.as_ref().to_str() {
130-
let msg = format!("Path \"{}\" is exist", msg);
130+
let msg = format!("Path \"{msg}\" is exist");
131131
return Err(crate::Error::PathUtilError(msg));
132132
}
133133
}
@@ -145,7 +145,7 @@ where
145145
let from = from.as_ref();
146146
if !from.exists() {
147147
if let Some(msg) = from.to_str() {
148-
let msg = format!("Path \"{}\" does not exist or you don't have access!", msg);
148+
let msg = format!("Path \"{msg}\" does not exist or you don't have access!");
149149
return Err(crate::Error::PathUtilError(msg));
150150
}
151151
return Err(crate::Error::PathUtilError(
@@ -154,7 +154,7 @@ where
154154
}
155155
if !from.is_dir() {
156156
if let Some(msg) = from.to_str() {
157-
let msg = format!("Path \"{}\" is not a directory!", msg);
157+
let msg = format!("Path \"{msg}\" is not a directory!");
158158
return Err(crate::Error::PathUtilError(msg));
159159
}
160160
return Err(crate::Error::PathUtilError(

tooling/bundler/src/bundle/platform.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,10 @@ pub fn target_triple() -> Result<String, crate::Error> {
9595
)));
9696
};
9797

98-
format!("{}-{}", os, env)
98+
format!("{os}-{env}")
9999
};
100100

101-
Ok(format!("{}-{}", arch, os))
101+
Ok(format!("{arch}-{os}"))
102102
}
103103

104104
#[cfg(test)]

tooling/bundler/src/bundle/settings.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -660,8 +660,7 @@ impl Settings {
660660
"windows" => vec![PackageType::WindowsMsi, PackageType::Nsis],
661661
os => {
662662
return Err(crate::Error::GenericError(format!(
663-
"Native {} bundles not yet supported.",
664-
os
663+
"Native {os} bundles not yet supported."
665664
)))
666665
}
667666
};

tooling/bundler/src/bundle/updater_bundle.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ fn bundle_update_windows(settings: &Settings, bundles: &[Bundle]) -> crate::Resu
215215
p.push(c);
216216
(p, b)
217217
});
218-
let archived_path = archived_path.with_extension(format!("{}.zip", bundle_name));
218+
let archived_path = archived_path.with_extension(format!("{bundle_name}.zip"));
219219

220220
info!(action = "Bundling"; "{}", display_path(&archived_path));
221221

tooling/bundler/src/bundle/windows/nsis.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,7 @@ fn build_nsis_app_installer(
130130
"aarch64" => "arm64",
131131
target => {
132132
return Err(crate::Error::ArchError(format!(
133-
"unsupported target: {}",
134-
target
133+
"unsupported target: {target}"
135134
)))
136135
}
137136
};

tooling/cli/node/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub fn run(args: Vec<String>, bin_name: Option<String>, callback: JsFunction) ->
1717
std::thread::spawn(move || match tauri_cli::try_run(args, bin_name) {
1818
Ok(_) => function.call(Ok(true), ThreadsafeFunctionCallMode::Blocking),
1919
Err(e) => function.call(
20-
Err(Error::new(Status::GenericFailure, format!("{:#}", e))),
20+
Err(Error::new(Status::GenericFailure, format!("{e:#}"))),
2121
ThreadsafeFunctionCallMode::Blocking,
2222
),
2323
});

tooling/cli/src/icon.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ pub fn command(options: Options) -> Result<()> {
8989
png_targets.extend(
9090
[32, 128]
9191
.into_iter()
92-
.map(|size| PngTarget::new(size, format!("{}x{}.png", size, size)))
92+
.map(|size| PngTarget::new(size, format!("{size}x{size}.png")))
9393
.collect::<Vec<PngTarget>>(),
9494
);
9595
png(&source, &out_dir, png_targets).context("Failed to generate png icons")?;
@@ -99,7 +99,7 @@ pub fn command(options: Options) -> Result<()> {
9999
&out_dir,
100100
png_icon_sizes
101101
.into_iter()
102-
.map(|size| PngTarget::new(size, format!("{}x{}.png", size, size)))
102+
.map(|size| PngTarget::new(size, format!("{size}x{size}.png")))
103103
.collect(),
104104
)?;
105105
}

tooling/cli/src/interface/rust.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -648,13 +648,7 @@ impl AppSettings for RustAppSettings {
648648
features: &[String],
649649
target: &str,
650650
) -> crate::Result<BundleSettings> {
651-
let arch64bits = if target.starts_with("x86_64") {
652-
true
653-
} else if target.starts_with("aarch64") {
654-
true
655-
} else {
656-
false
657-
};
651+
let arch64bits = target.starts_with("x86_64") || target.starts_with("aarch64");
658652

659653
tauri_config_to_bundle_settings(
660654
&self.manifest,

0 commit comments

Comments
 (0)