Skip to content

Commit bbc28fa

Browse files
authored
Implement Display for HashParts instead of ToString directly (#92)
* Implement Display for HashParts instead of ToString directly * Update hash_with_fixed_salt test to use bcrypt version 2b
1 parent a03a944 commit bbc28fa

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ pub enum Version {
5353
#[cfg(any(feature = "alloc", feature = "std"))]
5454
impl HashParts {
5555
/// Creates the bcrypt hash string from all its parts
56-
fn format(self) -> String {
56+
fn format(&self) -> String {
5757
self.format_for_version(Version::TwoB)
5858
}
5959

@@ -84,9 +84,9 @@ impl FromStr for HashParts {
8484
}
8585

8686
#[cfg(any(feature = "alloc", feature = "std"))]
87-
impl ToString for HashParts {
88-
fn to_string(&self) -> String {
89-
self.format_for_version(Version::TwoY)
87+
impl fmt::Display for HashParts {
88+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
89+
write!(f, "{}", self.format())
9090
}
9191
}
9292

@@ -534,7 +534,7 @@ mod tests {
534534
.unwrap()
535535
.to_string();
536536
assert_eq!(
537-
"$2y$05$HlFShUxTu4ZHHfOLJwfmCeDj/kuKFKboanXtDJXxCC7aIPTUgxNDe",
537+
"$2b$05$HlFShUxTu4ZHHfOLJwfmCeDj/kuKFKboanXtDJXxCC7aIPTUgxNDe",
538538
&hashed
539539
);
540540
}

0 commit comments

Comments
 (0)