summaryrefslogtreecommitdiff
path: root/solutions
diff options
context:
space:
mode:
Diffstat (limited to 'solutions')
-rw-r--r--solutions/09_strings/strings2.rs16
1 files changed, 15 insertions, 1 deletions
diff --git a/solutions/09_strings/strings2.rs b/solutions/09_strings/strings2.rs
index 4e18198..7de311f 100644
--- a/solutions/09_strings/strings2.rs
+++ b/solutions/09_strings/strings2.rs
@@ -1 +1,15 @@
-// Solutions will be available before the stable release. Thank you for testing the beta version 🥰
+fn is_a_color_word(attempt: &str) -> bool {
+ attempt == "green" || attempt == "blue" || attempt == "red"
+}
+
+fn main() {
+ let word = String::from("green");
+
+ if is_a_color_word(&word) {
+ // ^ added to have `&String` which is automatically
+ // coerced to `&str` by the compiler.
+ println!("That is a color word I know!");
+ } else {
+ println!("That is not a color word I know.");
+ }
+}