Skip to content

Commit

Permalink
rust: simplify string comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
Esgrove committed Aug 23, 2024
1 parent d2dc3ee commit a71c990
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions rust/src/othello.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,14 @@ impl Othello {
}

/// Ask a question with two options, and return bool from user answer.
// Associated aka static function (no self parameter)
// Associated aka static function (no self parameter).
fn get_answer(question: &str, yes: &str, no: &str) -> bool {
print!("{question} ({yes}/{no})? ");
io::stdout().flush().expect("Failed to flush stdout.");

let mut input = String::new();
io::stdin().read_line(&mut input).expect("Input failed");
return input.trim().to_lowercase() == *yes;
return input.trim().to_lowercase().as_str() == yes;
}

/// Ask and return the desired board size.
Expand Down

0 comments on commit a71c990

Please sign in to comment.