rustlings/exercises/09_strings/strings2.rs
2024-01-31 17:17:44 -05:00

23 lines
611 B
Rust

// strings2.rs
//
// Make me compile without changing the function signature!
//
// Execute `rustlings hint strings2` or use the `hint` watch subcommand for a
// hint.
fn main() {
let word = String::from("green"); // Try not changing this line :)
// This needs to be a string slice because the function is expecting a string slice.
if is_a_color_word(&word) {
println!("That is a color word I know!");
} else {
println!("That is not a color word I know.");
}
}
fn is_a_color_word(attempt: &str) -> bool {
attempt == "green" || attempt == "blue" || attempt == "red"
}