Skip to content

Commit

Permalink
BasicHash now implements Display trait
Browse files Browse the repository at this point in the history
  • Loading branch information
lookbusy1344 committed May 25, 2024
1 parent 25b5a72 commit 8cbd7b9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
9 changes: 9 additions & 0 deletions src/classes.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::fmt;

use git_version::git_version;
use strum::EnumString;

Expand Down Expand Up @@ -57,6 +59,13 @@ pub enum OutputEncoding {
/// Basic hash string. This is a wrapper around a String
pub struct BasicHash(pub String);

/// Implement Display for BasicHash
impl fmt::Display for BasicHash {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.0)
}
}

#[allow(clippy::struct_excessive_bools)]
#[readonly::make]
#[derive(Debug)]
Expand Down
6 changes: 3 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,11 +268,11 @@ fn file_hashes_st(config: &ConfigSettings, paths: &[String]) {
let file_hash = call_hasher(config.algorithm, config.encoding, pathstr);

match file_hash {
Ok(BasicHash(h)) => {
Ok(basic_hash) => {
if config.exclude_fn {
println!("{h}");
println!("{basic_hash}");
} else {
println!("{h} {pathstr}");
println!("{basic_hash} {pathstr}");
}
}
Err(e) => eprintln!("'{pathstr}' file err {e:?}"),
Expand Down

0 comments on commit 8cbd7b9

Please sign in to comment.