refactor: Apply clippy suggestions

This commit is contained in:
Lucas Schwiderski 2022-12-06 21:53:52 +01:00
parent 905734019e
commit 78eb25368c
Signed by: lucas
GPG key ID: AA12679AAA6DF4D8
7 changed files with 13 additions and 15 deletions

View file

@ -14,7 +14,7 @@ use crate::cmd::util::collect_bundle_paths;
fn parse_glob_pattern(s: &str) -> Result<Pattern, String> {
match Pattern::new(s) {
Ok(p) => Ok(p),
Err(e) => Err(format!("Invalid glob pattern '{}': {}", s, e)),
Err(e) => Err(format!("Invalid glob pattern '{s}': {e}")),
}
}
@ -297,7 +297,7 @@ pub(crate) async fn run(ctx: Arc<RwLock<sdk::Context>>, matches: &ArgMatches) ->
name.clone()
}
})
.unwrap_or(format!("{}", i));
.unwrap_or(format!("{i}"));
path.push(name);

View file

@ -89,7 +89,7 @@ pub(crate) async fn run(ctx: Arc<RwLock<sdk::Context>>, matches: &ArgMatches) ->
let ctx = ctx.read().await;
for group in groups {
let value = ctx.lookup_hash(*hash, (*group).into());
println!("{}", value);
println!("{value}");
}
Ok(())

View file

@ -125,7 +125,7 @@ mod tests {
for p in paths.iter() {
let name = p.file_name().and_then(std::ffi::OsStr::to_str).unwrap();
assert!(bundle_names.iter().find(|&n| n == &name).is_some());
assert!(bundle_names.iter().any(|n| n == &name));
}
}
}

View file

@ -132,7 +132,7 @@ where
}
};
Err(err).with_section(|| format!("{pos:#X} ({pos})", pos = pos).header("Position: "))
Err(err).with_section(|| format!("{pos:#X} ({pos})").header("Position: "))
}
pub(crate) async fn write_padding<W>(w: &mut W) -> Result<usize>

View file

@ -146,7 +146,7 @@ impl BundleFileType {
BundleFileType::WwiseStream => String::from("wwise_stream"),
BundleFileType::Xml => String::from("xml"),
BundleFileType::Unknown(s) => format!("{:016X}", s),
BundleFileType::Unknown(s) => format!("{s:016X}"),
}
}

View file

@ -34,7 +34,7 @@ impl Context {
s.to_owned()
} else {
tracing::debug!(%hash, "Murmur64 lookup failed");
format!("{:016X}", hash)
format!("{hash:016X}")
}
}
@ -48,7 +48,7 @@ impl Context {
s.to_owned()
} else {
tracing::debug!(%hash, "Murmur32 lookup failed");
format!("{:08X}", hash)
format!("{hash:08X}")
}
}
}
@ -69,6 +69,6 @@ where
s.to_owned()
} else {
tracing::debug!(%hash, "Murmur64 lookup failed");
format!("{:016X}", hash)
format!("{hash:016X}")
}
}

View file

@ -99,8 +99,7 @@ impl<'de> Visitor<'de> for Murmur64 {
match Murmur64::try_from(value) {
Ok(hash) => Ok(hash),
Err(err) => Err(E::custom(format!(
"failed to convert '{}' to Murmur64: {}",
value, err
"failed to convert '{value}' to Murmur64: {err}"
))),
}
}
@ -120,7 +119,7 @@ impl Serialize for Murmur64 {
where
S: Serializer,
{
serializer.serialize_str(&format!("{:016X}", self))
serializer.serialize_str(&format!("{self:016X}"))
}
}
@ -155,7 +154,7 @@ impl Serialize for Murmur32 {
where
S: Serializer,
{
serializer.serialize_str(&format!("{:08X}", self))
serializer.serialize_str(&format!("{self:08X}"))
}
}
@ -198,8 +197,7 @@ impl<'de> Visitor<'de> for Murmur32 {
match Murmur32::try_from(value) {
Ok(hash) => Ok(hash),
Err(err) => Err(E::custom(format!(
"failed to convert '{}' to Murmur32: {}",
value, err
"failed to convert '{value}' to Murmur32: {err}"
))),
}
}