diff options
Diffstat (limited to 'exercises')
| -rw-r--r-- | exercises/03_if/if2.rs | 22 | ||||
| -rw-r--r-- | exercises/08_enums/enums2.rs | 2 | ||||
| -rw-r--r-- | exercises/10_modules/modules2.rs | 1 | ||||
| -rw-r--r-- | exercises/15_traits/traits3.rs | 2 | ||||
| -rw-r--r-- | exercises/19_smart_pointers/rc1.rs | 1 |
5 files changed, 12 insertions, 16 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!"); } } diff --git a/exercises/08_enums/enums2.rs b/exercises/08_enums/enums2.rs index 29ed1b6..d70f639 100644 --- a/exercises/08_enums/enums2.rs +++ b/exercises/08_enums/enums2.rs @@ -1,5 +1,3 @@ -#![allow(dead_code)] - #[derive(Debug)] struct Point { x: u64, diff --git a/exercises/10_modules/modules2.rs b/exercises/10_modules/modules2.rs index 02eb80a..782a70e 100644 --- a/exercises/10_modules/modules2.rs +++ b/exercises/10_modules/modules2.rs @@ -1,7 +1,6 @@ // You can bring module paths into scopes and provide new names for them with // the `use` and `as` keywords. -#[allow(dead_code)] mod delicious_snacks { // TODO: Add the following two `use` statements after fixing them. // use self::fruits::PEAR as ???; diff --git a/exercises/15_traits/traits3.rs b/exercises/15_traits/traits3.rs index 2e8969e..c244650 100644 --- a/exercises/15_traits/traits3.rs +++ b/exercises/15_traits/traits3.rs @@ -1,5 +1,3 @@ -#![allow(dead_code)] - trait Licensed { // TODO: Add a default implementation for `licensing_info` so that // implementors like the two structs below can share that default behavior diff --git a/exercises/19_smart_pointers/rc1.rs b/exercises/19_smart_pointers/rc1.rs index 48e19dc..ecd3438 100644 --- a/exercises/19_smart_pointers/rc1.rs +++ b/exercises/19_smart_pointers/rc1.rs @@ -8,7 +8,6 @@ use std::rc::Rc; #[derive(Debug)] struct Sun; -#[allow(dead_code)] #[derive(Debug)] enum Planet { Mercury(Rc<Sun>), |
