mirror of
https://github.com/rust-lang/rustlings.git
synced 2026-01-12 21:59:18 +00:00
completed all tasks related to if/else
This commit is contained in:
parent
7c9577ab06
commit
81e9decacb
@ -1,9 +1,15 @@
|
|||||||
// if1.rs
|
// if1.rs
|
||||||
// Execute `rustlings hint if1` or use the `hint` watch subcommand for a hint.
|
// 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 {
|
pub fn bigger(a: i32, b: i32) -> i32 {
|
||||||
|
|
||||||
|
if a > b {
|
||||||
|
a
|
||||||
|
} else {
|
||||||
|
b
|
||||||
|
}
|
||||||
// Complete this function to return the bigger number!
|
// Complete this function to return the bigger number!
|
||||||
// Do not use:
|
// Do not use:
|
||||||
// - another function call
|
// - another function call
|
||||||
|
|||||||
@ -4,13 +4,18 @@
|
|||||||
// Step 2: Get the bar_for_fuzz and default_to_baz tests passing!
|
// 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.
|
// 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 {
|
pub fn foo_if_fizz(fizzish: &str) -> &str {
|
||||||
if fizzish == "fizz" {
|
if fizzish == "fizz" {
|
||||||
"foo"
|
"foo"
|
||||||
} else {
|
}else if fizzish == "fuzz" {
|
||||||
1
|
"bar"
|
||||||
|
}else if fizzish == "literally anything" {
|
||||||
|
"baz"
|
||||||
|
|
||||||
|
}else {
|
||||||
|
"1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
1
mypath
Submodule
1
mypath
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit c923e7af73a91970d2e63e03babbca9cc0817551
|
||||||
1
rustlings
Submodule
1
rustlings
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit c923e7af73a91970d2e63e03babbca9cc0817551
|
||||||
Loading…
x
Reference in New Issue
Block a user