Skip to content

Commit

Permalink
fix password strength example
Browse files Browse the repository at this point in the history
  • Loading branch information
ranile committed Aug 3, 2024
1 parent 6d56361 commit 4c1cbe7
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions examples/password_strength/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,16 @@ pub struct App {
}

impl App {
fn get_estimate(&self) -> Option<u8> {
zxcvbn(&self.password, &[])
.ok()
.map(|estimate| estimate.score())
fn get_estimate(&self) -> u8 {
let score = zxcvbn(&self.password, &[]).score();
score.into()
}

fn redout_top_row_text(&self) -> String {
if self.password.is_empty() {
return "Provide a password".to_string();
}
let estimate_text = match self.get_estimate().unwrap_or(0) {
let estimate_text = match self.get_estimate() {
0 => "That's a password?",
1 => "You can do a lot better.",
2 => "Meh",
Expand Down

0 comments on commit 4c1cbe7

Please sign in to comment.