File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -21,8 +21,8 @@ fn main() -> Result<(), Box<std::error::Error>> {
2121 for curse in & curses {
2222 occurrences. entry ( curse. to_string ( ) ) . or_insert ( 0 ) ;
2323 }
24- for word in "this is a fucking shit sentence with no goddamn shite in it" . split ( ' ' ) {
25- if curses . contains ( & word) {
24+ for word in "this is a fucking shit sentence with no goddamn shite in it" . split_whitespace ( ) {
25+ if naughty_word ( & word, & curses ) {
2626 occurrences. entry ( word. to_string ( ) ) . and_modify ( |i| * i += 1 ) ;
2727 }
2828 }
@@ -34,3 +34,10 @@ fn main() -> Result<(), Box<std::error::Error>> {
3434 println ! ( "{:#?}" , occurrences) ;
3535 Ok ( ( ) )
3636}
37+
38+ fn naughty_word ( word : & str , naughty_list : & Vec < & str > ) -> bool {
39+ if naughty_list. contains ( & word) {
40+ return true ;
41+ }
42+ false
43+ }
You can’t perform that action at this time.
0 commit comments