summaryrefslogtreecommitdiff
path: root/exercises
diff options
context:
space:
mode:
authorMo <76752051+mo8it@users.noreply.github.com>2024-09-16 12:54:20 +0200
committerGitHub <noreply@github.com>2024-09-16 12:54:20 +0200
commit2894f3c45c650172beaf2faaf43b190834a3538e (patch)
treecea6cff5ba2f33fd3042bb825a6fc814af809fbc /exercises
parent1bae2dcb0019d579cdfe5a0c68a9e46780eea6dd (diff)
parentb540c6df253c1f528486bf4245da8eec66710684 (diff)
Merge pull request #2110 from senekor/remo/skkynvtqxkoz
Make if2 less confusing
Diffstat (limited to 'exercises')
-rw-r--r--exercises/03_if/if2.rs22
1 files changed, 12 insertions, 10 deletions
diff --git a/exercises/03_if/if2.rs b/exercises/03_if/if2.rs
index 593a77a..10037f2 100644
--- a/exercises/03_if/if2.rs
+++ b/exercises/03_if/if2.rs
@@ -1,7 +1,7 @@
// TODO: Fix the compiler error on this function.
-fn foo_if_fizz(fizzish: &str) -> &str {
- if fizzish == "fizz" {
- "foo"
+fn picky_eater(food: &str) -> &str {
+ if food == "strawberry" {
+ "Yummy!"
} else {
1
}
@@ -18,18 +18,20 @@ mod tests {
use super::*;
#[test]
- fn foo_for_fizz() {
- // This means that calling `foo_if_fizz` with the argument "fizz" should return "foo".
- assert_eq!(foo_if_fizz("fizz"), "foo");
+ fn yummy_food() {
+ // This means that calling `picky_eater` with the argument "food" should return "Yummy!".
+ assert_eq!(picky_eater("strawberry"), "Yummy!");
}
#[test]
- fn bar_for_fuzz() {
- assert_eq!(foo_if_fizz("fuzz"), "bar");
+ fn neutral_food() {
+ assert_eq!(picky_eater("potato"), "I guess I can eat that.");
}
#[test]
- fn default_to_baz() {
- assert_eq!(foo_if_fizz("literally anything"), "baz");
+ fn default_disliked_food() {
+ assert_eq!(picky_eater("broccoli"), "No thanks!");
+ assert_eq!(picky_eater("gummy bears"), "No thanks!");
+ assert_eq!(picky_eater("literally anything"), "No thanks!");
}
}