diff options
| author | mo8it <mo8it@proton.me> | 2024-06-22 12:05:28 +0200 |
|---|---|---|
| committer | mo8it <mo8it@proton.me> | 2024-06-22 12:05:28 +0200 |
| commit | bd63ece47cbb6bde9e2fe53db543a8d22a246f5e (patch) | |
| tree | 1363e0164b7c4e54812996b4c4db2d7942cb17aa | |
| parent | 2901d856627889e5a52dcf9f97d1c77032081c08 (diff) | |
string1 solution
| -rw-r--r-- | exercises/09_strings/strings1.rs | 11 | ||||
| -rw-r--r-- | solutions/09_strings/strings1.rs | 10 |
2 files changed, 14 insertions, 7 deletions
diff --git a/exercises/09_strings/strings1.rs b/exercises/09_strings/strings1.rs index de762eb..6abdbb4 100644 --- a/exercises/09_strings/strings1.rs +++ b/exercises/09_strings/strings1.rs @@ -1,10 +1,9 @@ -// Make me compile without changing the function signature! +// TODO: Fix the compiler error without changing the function signature. +fn current_favorite_color() -> String { + "blue" +} fn main() { let answer = current_favorite_color(); - println!("My current favorite color is {}", answer); -} - -fn current_favorite_color() -> String { - "blue" + println!("My current favorite color is {answer}"); } diff --git a/solutions/09_strings/strings1.rs b/solutions/09_strings/strings1.rs index 4e18198..f7ba811 100644 --- a/solutions/09_strings/strings1.rs +++ b/solutions/09_strings/strings1.rs @@ -1 +1,9 @@ -// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 +fn current_favorite_color() -> String { + // Equivalent to `String::from("blue")` + "blue".to_string() +} + +fn main() { + let answer = current_favorite_color(); + println!("My current favorite color is {answer}"); +} |
