rustlings/exercises/strings/strings2.rs

17 lines
478 B
Rust
Raw Permalink Normal View History

2021-07-08 02:58:36 +07:00
// strings2.rs
// Make me compile without changing the function signature!
// Execute `rustlings hint strings2` for hints :)
fn main() {
let word = String::from("green"); // Try not changing this line :)
if is_a_color_word(word) {
println!("That is a color word I know!");
} else {
println!("That is not a color word I know.");
}
}
2021-07-08 03:02:31 +07:00
fn is_a_color_word(attempt: String) -> bool {
2021-07-08 02:58:36 +07:00
attempt == "green" || attempt == "blue" || attempt == "red"
}