Skip to content

Commit

Permalink
fix(clippy): resolve linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
kade-robertson authored and zkat committed Feb 9, 2023
1 parent a37dfc9 commit 354f686
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
10 changes: 5 additions & 5 deletions src/algorithm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub enum Algorithm {

impl fmt::Display for Algorithm {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", format!("{:?}", self).to_lowercase())
write!(f, "{}", format!("{self:?}").to_lowercase())
}
}

Expand All @@ -44,10 +44,10 @@ mod tests {

#[test]
fn algorithm_formatting() {
assert_eq!(format!("{}", Sha1), "sha1");
assert_eq!(format!("{}", Sha256), "sha256");
assert_eq!(format!("{}", Sha384), "sha384");
assert_eq!(format!("{}", Sha512), "sha512");
assert_eq!(format!("{Sha1}"), "sha1");
assert_eq!(format!("{Sha256}"), "sha256");
assert_eq!(format!("{Sha384}"), "sha384");
assert_eq!(format!("{Sha512}"), "sha512");
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion src/checker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ mod tests {
.parse::<Integrity>()
.unwrap()
.concat(Integrity::from(b"hello world"));
eprintln!("\n{}", sri);
eprintln!("\n{sri}");
let result = IntegrityChecker::new(sri).chain(b"hello world").result();
assert_eq!(result.unwrap(), Algorithm::Sha256)
}
Expand Down
10 changes: 6 additions & 4 deletions src/opts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ use crate::algorithm::Algorithm;
use crate::hash::Hash;
use crate::integrity::Integrity;

use base64::prelude::BASE64_STANDARD;
use base64::Engine;
use digest::Digest;

#[allow(clippy::enum_variant_names)]
Expand Down Expand Up @@ -90,10 +92,10 @@ impl IntegrityOpts {
.into_iter()
.map(|h| {
let (algorithm, data) = match h {
Hasher::Sha1(h) => (Algorithm::Sha1, base64::encode(&h.finalize())),
Hasher::Sha256(h) => (Algorithm::Sha256, base64::encode(&h.finalize())),
Hasher::Sha384(h) => (Algorithm::Sha384, base64::encode(&h.finalize())),
Hasher::Sha512(h) => (Algorithm::Sha512, base64::encode(&h.finalize())),
Hasher::Sha1(h) => (Algorithm::Sha1, BASE64_STANDARD.encode(h.finalize())),
Hasher::Sha256(h) => (Algorithm::Sha256, BASE64_STANDARD.encode(h.finalize())),
Hasher::Sha384(h) => (Algorithm::Sha384, BASE64_STANDARD.encode(h.finalize())),
Hasher::Sha512(h) => (Algorithm::Sha512, BASE64_STANDARD.encode(h.finalize())),
};
Hash {
algorithm,
Expand Down

0 comments on commit 354f686

Please sign in to comment.