Apply clippy lints
This commit is contained in:
parent
a36a59d907
commit
d61ffdfef2
20 changed files with 39 additions and 40 deletions
|
@ -469,7 +469,7 @@ async fn patch_boot_bundle(state: Arc<ActionState>, deployment_info: &str) -> Re
|
|||
}
|
||||
.instrument(tracing::trace_span!("read boot bundle"))
|
||||
.await
|
||||
.wrap_err_with(|| format!("Failed to read bundle '{}'", BOOT_BUNDLE_NAME))?;
|
||||
.wrap_err_with(|| format!("Failed to read bundle '{BOOT_BUNDLE_NAME}'"))?;
|
||||
|
||||
{
|
||||
tracing::trace!("Adding mod package file to boot bundle");
|
||||
|
|
|
@ -208,7 +208,7 @@ pub(crate) async fn reset_mod_deployment(state: ActionState) -> Result<()> {
|
|||
|
||||
for p in paths {
|
||||
let path = bundle_dir.join(p);
|
||||
let backup = bundle_dir.join(format!("{}.bak", p));
|
||||
let backup = bundle_dir.join(format!("{p}.bak"));
|
||||
|
||||
let res = async {
|
||||
tracing::debug!(
|
||||
|
|
|
@ -363,7 +363,7 @@ fn extract_legacy_mod<R: Read + Seek>(
|
|||
for i in 0..file_count {
|
||||
let mut f = archive
|
||||
.by_index(i)
|
||||
.wrap_err_with(|| format!("Failed to get file at index {}", i))?;
|
||||
.wrap_err_with(|| format!("Failed to get file at index {i}"))?;
|
||||
|
||||
let Some(name) = f.enclosed_name().map(|p| p.to_path_buf()) else {
|
||||
let err = eyre::eyre!("File name in archive is not a safe path value.").suggestion(
|
||||
|
@ -426,7 +426,7 @@ pub(crate) async fn import_from_file(state: ActionState, info: FileInfo) -> Resu
|
|||
let mod_info = api
|
||||
.mods_id(id)
|
||||
.await
|
||||
.wrap_err_with(|| format!("Failed to query mod {} from Nexus", id))?;
|
||||
.wrap_err_with(|| format!("Failed to query mod {id} from Nexus"))?;
|
||||
|
||||
let version = match api.file_version(id, timestamp).await {
|
||||
Ok(version) => version,
|
||||
|
@ -461,13 +461,13 @@ pub(crate) async fn import_from_file(state: ActionState, info: FileInfo) -> Resu
|
|||
pub(crate) async fn import_from_nxm(state: ActionState, uri: String) -> Result<ModInfo> {
|
||||
let url = uri
|
||||
.parse()
|
||||
.wrap_err_with(|| format!("Invalid Uri '{}'", uri))?;
|
||||
.wrap_err_with(|| format!("Invalid Uri '{uri}'"))?;
|
||||
|
||||
let api = NexusApi::new(state.nexus_api_key.to_string())?;
|
||||
let (mod_info, file_info, data) = api
|
||||
.handle_nxm(url)
|
||||
.await
|
||||
.wrap_err_with(|| format!("Failed to download mod from NXM uri '{}'", uri))?;
|
||||
.wrap_err_with(|| format!("Failed to download mod from NXM uri '{uri}'"))?;
|
||||
|
||||
let nexus = NexusInfo::from(mod_info);
|
||||
import_mod(state, Some((nexus, file_info.version)), data).await
|
||||
|
@ -524,7 +524,7 @@ pub(crate) async fn import_mod(
|
|||
let data = api
|
||||
.picture(url)
|
||||
.await
|
||||
.wrap_err_with(|| format!("Failed to download Nexus image from '{}'", url))?;
|
||||
.wrap_err_with(|| format!("Failed to download Nexus image from '{url}'"))?;
|
||||
|
||||
let img = image_data_to_buffer(&data)?;
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ fn notify_nxm_download(
|
|||
.to_ns_name::<GenericNamespaced>()
|
||||
.expect("Invalid socket name"),
|
||||
)
|
||||
.wrap_err_with(|| format!("Failed to connect to '{}'", IPC_ADDRESS))
|
||||
.wrap_err_with(|| format!("Failed to connect to '{IPC_ADDRESS}'"))
|
||||
.suggestion("Make sure the main window is open.")?;
|
||||
|
||||
tracing::debug!("Connected to main process at '{}'", IPC_ADDRESS);
|
||||
|
@ -159,7 +159,7 @@ fn main() -> Result<()> {
|
|||
|
||||
loop {
|
||||
let res = server.accept().wrap_err_with(|| {
|
||||
format!("IPC server failed to listen on '{}'", IPC_ADDRESS)
|
||||
format!("IPC server failed to listen on '{IPC_ADDRESS}'")
|
||||
});
|
||||
|
||||
match res {
|
||||
|
|
|
@ -108,20 +108,19 @@ impl std::fmt::Debug for AsyncAction {
|
|||
match self {
|
||||
AsyncAction::DeployMods(_) => write!(f, "AsyncAction::DeployMods(_state)"),
|
||||
AsyncAction::ResetDeployment(_) => write!(f, "AsyncAction::ResetDeployment(_state)"),
|
||||
AsyncAction::AddMod(_, info) => write!(f, "AsyncAction::AddMod(_state, {:?})", info),
|
||||
AsyncAction::AddMod(_, info) => write!(f, "AsyncAction::AddMod(_state, {info:?})"),
|
||||
AsyncAction::DeleteMod(_, info) => {
|
||||
write!(f, "AsyncAction::DeleteMod(_state, {:?})", info)
|
||||
write!(f, "AsyncAction::DeleteMod(_state, {info:?})")
|
||||
}
|
||||
AsyncAction::SaveSettings(_) => write!(f, "AsyncAction::SaveSettings(_state)"),
|
||||
AsyncAction::CheckUpdates(_) => write!(f, "AsyncAction::CheckUpdates(_state)"),
|
||||
AsyncAction::LoadInitial((path, is_default)) => write!(
|
||||
f,
|
||||
"AsyncAction::LoadInitial(({:?}, {:?}))",
|
||||
path, is_default
|
||||
"AsyncAction::LoadInitial(({path:?}, {is_default:?}))"
|
||||
),
|
||||
AsyncAction::Log(_) => write!(f, "AsyncAction::Log(_)"),
|
||||
AsyncAction::NxmDownload(_, uri) => {
|
||||
write!(f, "AsyncAction::NxmDownload(_state, {})", uri)
|
||||
write!(f, "AsyncAction::NxmDownload(_state, {uri})")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -448,7 +447,7 @@ impl AppDelegate<State> for Delegate {
|
|||
if let Err(err) = open::that_detached(Arc::as_ref(url)) {
|
||||
tracing::error!(
|
||||
"{:?}",
|
||||
Report::new(err).wrap_err(format!("Failed to open url '{}'", url))
|
||||
Report::new(err).wrap_err(format!("Failed to open url '{url}'"))
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ impl ColorExt for Color {
|
|||
fn darken(&self, fac: f32) -> Self {
|
||||
let (r, g, b, a) = self.as_rgba();
|
||||
let rgb = Rgb::from(r as f32, g as f32, b as f32);
|
||||
let rgb = rgb.lighten(-1. * fac);
|
||||
let rgb = rgb.lighten(-fac);
|
||||
Self::rgba(
|
||||
rgb.get_red() as f64,
|
||||
rgb.get_green() as f64,
|
||||
|
|
|
@ -5,6 +5,7 @@ use druid::{
|
|||
|
||||
use crate::state::{State, ACTION_SET_DIRTY, ACTION_START_SAVE_SETTINGS};
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub struct DisabledButtonController;
|
||||
|
||||
impl<T: Data> Controller<T, Button<T>> for DisabledButtonController {
|
||||
|
|
|
@ -34,9 +34,9 @@ pub fn error<T: Data>(err: Report, _parent: WindowHandle) -> WindowDesc<T> {
|
|||
// The second to last one, the context to the root cause
|
||||
let context = err.chain().nth(count - 2).unwrap();
|
||||
|
||||
(format!("{first}!"), format!("{}: {}", context, root))
|
||||
(format!("{first}!"), format!("{context}: {root}"))
|
||||
} else {
|
||||
("An error occurred!".to_string(), format!("{}: {}", first, root))
|
||||
("An error occurred!".to_string(), format!("{first}: {root}"))
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -348,7 +348,7 @@ fn build_mod_details_info() -> impl Widget<State> {
|
|||
let nexus_link = Maybe::or_empty(|| {
|
||||
let link = Label::raw().lens(NexusInfo::id.map(
|
||||
|id| {
|
||||
let url = format!("https://nexusmods.com/warhammer40kdarktide/mods/{}", id);
|
||||
let url = format!("https://nexusmods.com/warhammer40kdarktide/mods/{id}");
|
||||
let mut builder = RichTextBuilder::new();
|
||||
builder
|
||||
.push("Open on Nexusmods")
|
||||
|
|
|
@ -94,10 +94,10 @@ pub(crate) async fn run(ctx: sdk::Context, matches: &ArgMatches) -> Result<()> {
|
|||
|
||||
match bundle_name {
|
||||
IdString64::String(name) => {
|
||||
println!("{:016x} {}", bundle_hash, name);
|
||||
println!("{bundle_hash:016x} {name}");
|
||||
}
|
||||
IdString64::Hash(hash) => {
|
||||
println!("{:016x}", hash);
|
||||
println!("{hash:016x}");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -110,7 +110,7 @@ pub(crate) async fn run(ctx: sdk::Context, matches: &ArgMatches) -> Result<()> {
|
|||
println!("\t{:016x}.{:<12} {}", file.name, extension, name);
|
||||
}
|
||||
IdString64::Hash(hash) => {
|
||||
println!("\t{:016x}.{}", hash, extension);
|
||||
println!("\t{hash:016x}.{extension}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -127,10 +127,10 @@ pub(crate) async fn run(ctx: sdk::Context, matches: &ArgMatches) -> Result<()> {
|
|||
|
||||
match bundle_name {
|
||||
IdString64::String(name) => {
|
||||
println!("{:016x} {}", bundle_hash, name);
|
||||
println!("{bundle_hash:016x} {name}");
|
||||
}
|
||||
IdString64::Hash(hash) => {
|
||||
println!("{:016x}", hash);
|
||||
println!("{hash:016x}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -158,7 +158,7 @@ pub(crate) async fn run(ctx: sdk::Context, matches: &ArgMatches) -> Result<()> {
|
|||
|
||||
for bundle in bundles {
|
||||
found = true;
|
||||
println!("{:016x}", bundle);
|
||||
println!("{bundle:016x}");
|
||||
}
|
||||
|
||||
if !found {
|
||||
|
|
|
@ -473,7 +473,7 @@ where
|
|||
}
|
||||
}
|
||||
Err(err) => {
|
||||
let err = err.wrap_err(format!("Failed to decompile file {}", name));
|
||||
let err = err.wrap_err(format!("Failed to decompile file {name}"));
|
||||
tracing::error!("{:?}", err);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -147,7 +147,7 @@ pub(crate) async fn run(ctx: sdk::Context, matches: &ArgMatches) -> Result<()> {
|
|||
|
||||
let patch_number = matches
|
||||
.get_one::<u16>("patch")
|
||||
.map(|num| format!("{:03}", num));
|
||||
.map(|num| format!("{num:03}"));
|
||||
|
||||
let output_path = matches
|
||||
.get_one::<PathBuf>("output")
|
||||
|
@ -156,7 +156,7 @@ pub(crate) async fn run(ctx: sdk::Context, matches: &ArgMatches) -> Result<()> {
|
|||
let mut output_path = bundle_path.clone();
|
||||
|
||||
if let Some(patch_number) = patch_number.as_ref() {
|
||||
output_path.set_extension(format!("patch_{:03}", patch_number));
|
||||
output_path.set_extension(format!("patch_{patch_number:03}"));
|
||||
}
|
||||
|
||||
output_path
|
||||
|
@ -196,7 +196,7 @@ pub(crate) async fn run(ctx: sdk::Context, matches: &ArgMatches) -> Result<()> {
|
|||
span.record("output_path", output_path.display().to_string());
|
||||
span.record("raw", sub_matches.get_flag("raw"));
|
||||
span.record("target_name", target_name.display().to_string());
|
||||
span.record("file_type", format!("{:?}", file_type));
|
||||
span.record("file_type", format!("{file_type:?}"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ enum OutputFormat {
|
|||
|
||||
fn format_byte_size(size: usize) -> String {
|
||||
if size < 1024 {
|
||||
format!("{} Bytes", size)
|
||||
format!("{size} Bytes")
|
||||
} else if size < 1024 * 1024 {
|
||||
format!("{} kB", size / 1024)
|
||||
} else if size < 1024 * 1024 * 1024 {
|
||||
|
|
|
@ -164,7 +164,7 @@ pub(crate) async fn run(_ctx: sdk::Context, matches: &ArgMatches) -> Result<()>
|
|||
.iter()
|
||||
.map(|(path_tmpl, content_tmpl)| {
|
||||
env.render_str(path_tmpl, &render_ctx)
|
||||
.wrap_err_with(|| format!("Failed to render template: {}", path_tmpl))
|
||||
.wrap_err_with(|| format!("Failed to render template: {path_tmpl}"))
|
||||
.and_then(|path| {
|
||||
env.render_named_str(&path, content_tmpl, &render_ctx)
|
||||
.wrap_err_with(|| format!("Failed to render template '{}'", &path))
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#![feature(io_error_more)]
|
||||
#![feature(let_chains)]
|
||||
#![feature(result_flattening)]
|
||||
#![feature(test)]
|
||||
#![windows_subsystem = "console"]
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ pub const TIME_FORMAT: &[FormatItem] = format_description!("[hour]:[minute]:[sec
|
|||
|
||||
pub fn format_fields(w: &mut Writer<'_>, field: &Field, val: &dyn std::fmt::Debug) -> Result {
|
||||
if field.name() == "message" {
|
||||
write!(w, "{:?}", val)
|
||||
write!(w, "{val:?}")
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ where
|
|||
writer,
|
||||
"[{}] [{:>5}] ",
|
||||
time,
|
||||
color.bold().paint(format!("{}", level))
|
||||
color.bold().paint(format!("{level}"))
|
||||
)?;
|
||||
|
||||
ctx.field_format().format_fields(writer.by_ref(), event)?;
|
||||
|
|
|
@ -99,7 +99,7 @@ impl Api {
|
|||
|
||||
#[tracing::instrument(skip(self))]
|
||||
pub async fn mods_id(&self, id: u64) -> Result<Mod> {
|
||||
let url = BASE_URL_GAME.join(&format!("mods/{}.json", id))?;
|
||||
let url = BASE_URL_GAME.join(&format!("mods/{id}.json"))?;
|
||||
let req = self.client.get(url);
|
||||
self.send(req).await
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ fn main() {
|
|||
} else {
|
||||
"oo2core_win64"
|
||||
};
|
||||
println!("cargo:rustc-link-lib=static={}", lib_name);
|
||||
println!("cargo:rustc-link-lib=static={lib_name}");
|
||||
} else {
|
||||
println!("cargo:rustc-link-lib=static=oo2corelinux64");
|
||||
println!("cargo:rustc-link-lib=stdc++");
|
||||
|
|
|
@ -247,7 +247,7 @@ pub mod sync {
|
|||
fn read_string_len(mut r: impl Read, len: usize) -> Result<String> {
|
||||
let mut buf = vec![0; len];
|
||||
r.read_exact(&mut buf)
|
||||
.wrap_err_with(|| format!("Failed to read {} bytes", len))?;
|
||||
.wrap_err_with(|| format!("Failed to read {len} bytes"))?;
|
||||
|
||||
let res = match CStr::from_bytes_until_nul(&buf) {
|
||||
Ok(s) => {
|
||||
|
@ -259,6 +259,6 @@ pub mod sync {
|
|||
|
||||
res.wrap_err("Invalid binary for UTF8 string")
|
||||
.with_section(|| format!("{}", String::from_utf8_lossy(&buf)).header("ASCI:"))
|
||||
.with_section(|| format!("{:x?}", buf).header("Bytes:"))
|
||||
.with_section(|| format!("{buf:x?}").header("Bytes:"))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ impl fmt::LowerHex for Murmur64 {
|
|||
|
||||
impl fmt::Display for Murmur64 {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "{:016X}", self)
|
||||
write!(f, "{self:016X}")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -158,7 +158,7 @@ impl fmt::LowerHex for Murmur32 {
|
|||
|
||||
impl fmt::Display for Murmur32 {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "{:08X}", self)
|
||||
write!(f, "{self:08X}")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue