fn three_vowels(word: &str) -> bool {
let mut vowel_count = 0;
for c in word.chars() {
match c {
'a' | 'e' | 'i' | 'o' | 'u' => {
vowel_count += 1;
if vowel_count >= 3 {
return true
}
}
_ => vowel_count = 0
}
}
false
}
Isn't _ => vowel_count = 0 wrong ? Shouldn't it just do nothing instead of resetting the vowel_count to 0 every time when a non-vowel character is found ?
I saw the example on https://github.com/rust-unofficial/patterns/blob/main/idioms/coercion-arguments.md
Isn't
_ => vowel_count = 0
wrong ? Shouldn't it just do nothing instead of resetting thevowel_count
to0
every time when a non-vowel character is found ?