From 81e9decacb9c90a1a53aaa6d0e91f219799ab24c Mon Sep 17 00:00:00 2001 From: Max Boewer Date: Fri, 18 Nov 2022 22:08:30 +0100 Subject: [PATCH] completed all tasks related to if/else --- exercises/if/if1.rs | 8 +++++++- exercises/if/if2.rs | 11 ++++++++--- mypath | 1 + rustlings | 1 + 4 files changed, 17 insertions(+), 4 deletions(-) create mode 160000 mypath create mode 160000 rustlings diff --git a/exercises/if/if1.rs b/exercises/if/if1.rs index 587e03f8..825daf28 100644 --- a/exercises/if/if1.rs +++ b/exercises/if/if1.rs @@ -1,9 +1,15 @@ // if1.rs // 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 { + + if a > b { + a + } else { + b + } // Complete this function to return the bigger number! // Do not use: // - another function call diff --git a/exercises/if/if2.rs b/exercises/if/if2.rs index effddbb6..7512f14f 100644 --- a/exercises/if/if2.rs +++ b/exercises/if/if2.rs @@ -4,13 +4,18 @@ // Step 2: Get the bar_for_fuzz and default_to_baz tests passing! // 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 { - 1 + }else if fizzish == "fuzz" { + "bar" + }else if fizzish == "literally anything" { + "baz" + + }else { + "1" } } diff --git a/mypath b/mypath new file mode 160000 index 00000000..c923e7af --- /dev/null +++ b/mypath @@ -0,0 +1 @@ +Subproject commit c923e7af73a91970d2e63e03babbca9cc0817551 diff --git a/rustlings b/rustlings new file mode 160000 index 00000000..c923e7af --- /dev/null +++ b/rustlings @@ -0,0 +1 @@ +Subproject commit c923e7af73a91970d2e63e03babbca9cc0817551