Skip to content

Commit

Permalink
Derive serde traits for Score.
Browse files Browse the repository at this point in the history
  • Loading branch information
tmpfs committed May 24, 2024
1 parent 6e870de commit b00cdbb
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions src/scoring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use std::{cmp, fmt::Display};
/// Score of a password check.
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, PartialOrd, Ord)]
#[non_exhaustive]
#[cfg_attr(feature = "ser", derive(serde::Serialize, serde::Deserialize))]
pub enum Score {
/// Can be cracked with 10^3 guesses or less.
Zero = 0,
Expand All @@ -31,13 +32,6 @@ impl Display for Score {
}
}

#[cfg(feature = "ser")]
impl serde::Serialize for Score {
fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
i8::from(*self).serialize(serializer)
}
}

#[derive(Debug, Clone)]
pub struct GuessCalculation {
/// Estimated guesses needed to crack the password
Expand Down

0 comments on commit b00cdbb

Please sign in to comment.