diff options
Diffstat (limited to 'rustlings/exercises/03_if')
| -rw-r--r-- | rustlings/exercises/03_if/if1.rs | 10 | ||||
| -rw-r--r-- | rustlings/exercises/03_if/if2.rs | 4 | ||||
| -rw-r--r-- | rustlings/exercises/03_if/if3.rs | 5 |
3 files changed, 10 insertions, 9 deletions
diff --git a/rustlings/exercises/03_if/if1.rs b/rustlings/exercises/03_if/if1.rs index e5a3c5a..079c671 100644 --- a/rustlings/exercises/03_if/if1.rs +++ b/rustlings/exercises/03_if/if1.rs @@ -1,9 +1,9 @@ fn bigger(a: i32, b: i32) -> i32 { - // TODO: Complete this function to return the bigger number! - // If both numbers are equal, any of them can be returned. - // Do not use: - // - another function call - // - additional variables + if a > b { + a + } else { + b + } } fn main() { diff --git a/rustlings/exercises/03_if/if2.rs b/rustlings/exercises/03_if/if2.rs index ca8493c..8104487 100644 --- a/rustlings/exercises/03_if/if2.rs +++ b/rustlings/exercises/03_if/if2.rs @@ -2,8 +2,10 @@ fn picky_eater(food: &str) -> &str { if food == "strawberry" { "Yummy!" + } else if food == "potato" { + "I guess I can eat that." } else { - 1 + "No thanks!" } } diff --git a/rustlings/exercises/03_if/if3.rs b/rustlings/exercises/03_if/if3.rs index 89164eb..fee96f8 100644 --- a/rustlings/exercises/03_if/if3.rs +++ b/rustlings/exercises/03_if/if3.rs @@ -1,13 +1,12 @@ fn animal_habitat(animal: &str) -> &str { - // TODO: Fix the compiler error in the statement below. let identifier = if animal == "crab" { 1 } else if animal == "gopher" { - 2.0 + 2 } else if animal == "snake" { 3 } else { - "Unknown" + 0 }; // Don't change the expression below! |