aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoris2022-10-22 09:34:27 +0200
committerJoris2022-10-22 09:34:27 +0200
commit67856e653f49663dc72cbb01504e7ac9148f7ebe (patch)
treece783e7317f5a5dc8dd5c4c09b1fa87de8f3b97d
parent902be75848b99b4f60bbd74cd305b899afeeac78 (diff)
downloadflashcards-67856e653f49663dc72cbb01504e7ac9148f7ebe.tar.gz
flashcards-67856e653f49663dc72cbb01504e7ac9148f7ebe.tar.bz2
flashcards-67856e653f49663dc72cbb01504e7ac9148f7ebe.zip
Remove whitespaces in response
Around and between words. This prevent saying a response is false when the only difference is whitespaces.
-rw-r--r--src/gui/question.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/gui/question.rs b/src/gui/question.rs
index 1c4f179..727daa9 100644
--- a/src/gui/question.rs
+++ b/src/gui/question.rs
@@ -202,8 +202,8 @@ pub fn ask<B: Backend>(
}
fn is_correct(input: &str, responses: &[String]) -> bool {
- // Trim input
- let input = input.trim();
+ // Remove whitespaces
+ let input = input.split_whitespace().map(|word| word.trim()).collect::<Vec<&str>>().join(" ");
responses
.iter()