#[macro_use]externcratelazy_static;pubfnvowel_count(some_string:&str)->usize{lazy_static!{staticrefVOWELS:Vec<char>=vec!['a','e','i','o','u'];}some_string.to_ascii_lowercase().chars().filter(|c|VOWELS.contains(c)).count()}#[cfg(test)]modtests{usecrate::vowel_count;#[test]fnit_works_with_an_empty_string(){assert_eq!(vowel_count(""),0);}#[test]fnit_works_non_vowel_strings(){assert_eq!(vowel_count("d"),0);assert_eq!(vowel_count("drthpCVM *&^"),0);assert_eq!(vowel_count("1234567890!@#$%^&*()--__+="),0);assert_eq!(vowel_count("NPlkv.,<>?/"),0);}#[test]fnit_works_for_strings_of_just_vowels(){assert_eq!(vowel_count("a"),1);assert_eq!(vowel_count("A"),1);assert_eq!(vowel_count("AaeEiIoOuU"),10);assert_eq!(vowel_count("eoiuioEAUIAEoieaiAoe"),20);}#[test]fnit_works_for_mixed_strings(){assert_eq!(vowel_count("deadpool"),4);assert_eq!(vowel_count("This is just a sentence! With some words and symbols #$%"),13);assert_eq!(vowel_count("TESTING OUT YELLING WITH ALL CAPS"),9);assert_eq!(vowel_count("!@# \nThis is THE MOST COMPLICATED test SoO farrrr"),12);}}
I'm still live streaming as I type this out, but once I wrap up I'll post a link to the video here!
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Here is my Rust solution all TDD'ed out!
I'm still live streaming as I type this out, but once I wrap up I'll post a link to the video here!