Skip to content

Commit

Permalink
refactor: apply clippy suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
orhun committed Oct 22, 2023
1 parent 394bb11 commit 919a808
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions core/src/github/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ use crate::tracker::ProgressTracker;
use crate::Game;
use api::Releases;
use ring::digest::{Context, SHA256};
use std::fmt::Write;
use std::fs::File;
use std::io::{BufReader, Read};
use std::io::{Error as IoError, ErrorKind as IoErrorKind, Result as IoResult};
use std::path::Path;

pub struct GitHubClient {
Expand Down Expand Up @@ -89,8 +91,11 @@ impl GitHubClient {
.iter()
.collect::<Vec<&u8>>()
.iter()
.map(|byte| format!("{byte:02x}"))
.collect::<String>();
.try_fold::<String, _, IoResult<String>>(String::new(), |mut output, b| {
write!(output, "{b:02x}")
.map_err(|e| IoError::new(IoErrorKind::Other, e.to_string()))?;
Ok(output)
})?;
if digest != sha256sum.trim() {
Err(Error::Verify(format!(
"checksum mismatch: expected {digest:?}, got {sha256sum:?}"
Expand Down

0 comments on commit 919a808

Please sign in to comment.