From 171deb32ca1d7841ca1757c6599b5ebed4319cee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Franke?= Date: Wed, 26 Jul 2023 13:35:07 +0200 Subject: [PATCH] Implement if excercises --- exercises/if/if1.rs | 3 +-- exercises/if/if2.rs | 6 +++--- exercises/if/if3.rs | 6 ++---- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/exercises/if/if1.rs b/exercises/if/if1.rs index d8108a0f..02f66a98 100644 --- a/exercises/if/if1.rs +++ b/exercises/if/if1.rs @@ -2,13 +2,12 @@ // // Execute `rustlings hint if1` or use the `hint` watch subcommand for a hint. -// I AM NOT DONE - pub fn bigger(a: i32, b: i32) -> i32 { // Complete this function to return the bigger number! // Do not use: // - another function call // - additional variables + return if (a > b) { a } else { b }; } // Don't mind this for now :) diff --git a/exercises/if/if2.rs b/exercises/if/if2.rs index f512f13f..9ae278f2 100644 --- a/exercises/if/if2.rs +++ b/exercises/if/if2.rs @@ -5,13 +5,13 @@ // // Execute `rustlings hint if2` or use the `hint` watch subcommand for a hint. -// I AM NOT DONE - pub fn foo_if_fizz(fizzish: &str) -> &str { if fizzish == "fizz" { "foo" + } else if fizzish == "fuzz" { + "bar" } else { - 1 + "baz" } } diff --git a/exercises/if/if3.rs b/exercises/if/if3.rs index 73a7025b..32e03b0e 100644 --- a/exercises/if/if3.rs +++ b/exercises/if/if3.rs @@ -2,17 +2,15 @@ // // Execute `rustlings hint if3` or use the `hint` watch subcommand for a hint. -// I AM NOT DONE - pub fn animal_habitat(animal: &str) -> &'static str { let identifier = if animal == "crab" { 1 } else if animal == "gopher" { - 2.0 + 2 } else if animal == "snake" { 3 } else { - "Unknown" + 0 }; // DO NOT CHANGE THIS STATEMENT BELOW