From 9a5df9311d73f5a081d81962af69c65a5df80514 Mon Sep 17 00:00:00 2001 From: Nevin Aragam Date: Thu, 18 Jan 2024 23:37:06 -0700 Subject: [PATCH] fix: solved 03_if --- exercises/03_if/if1.rs | 13 ++++++------- exercises/03_if/if2.rs | 6 +++--- exercises/03_if/if3.rs | 4 ++-- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/exercises/03_if/if1.rs b/exercises/03_if/if1.rs index 4734d78f..adf89183 100644 --- a/exercises/03_if/if1.rs +++ b/exercises/03_if/if1.rs @@ -1,14 +1,13 @@ // if1.rs // -// Execute `rustlings hint if1` or use the `hint` watch subcommand for a hint. - -// I AM NOT DONE +// Execute `rustlings hint if1` or use the `hint` watch subcommand for a hint. pub fn bigger(a: i32, b: i32) -> i32 { - // Complete this function to return the bigger number! - // Do not use: - // - another function call - // - additional variables + if (a > b) { + a + } else { + b + } } // Don't mind this for now :) diff --git a/exercises/03_if/if2.rs b/exercises/03_if/if2.rs index f512f13f..9ae278f2 100644 --- a/exercises/03_if/if2.rs +++ b/exercises/03_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/03_if/if3.rs b/exercises/03_if/if3.rs index 16962740..e148c4b2 100644 --- a/exercises/03_if/if3.rs +++ b/exercises/03_if/if3.rs @@ -8,11 +8,11 @@ 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" + -1 }; // DO NOT CHANGE THIS STATEMENT BELOW