Going through rustlings for the first time
at main 451 B view raw
1fn is_a_color_word(attempt: &str) -> bool { 2 attempt == "green" || attempt == "blue" || attempt == "red" 3} 4 5fn main() { 6 let word = String::from("green"); 7 8 if is_a_color_word(&word) { 9 // ^ added to have `&String` which is automatically 10 // coerced to `&str` by the compiler. 11 println!("That is a color word I know!"); 12 } else { 13 println!("That is not a color word I know."); 14 } 15}