mirror of
https://github.com/rust-lang/rustlings.git
synced 2025-12-28 14:59:18 +00:00
First quiz done
This commit is contained in:
parent
ba0854d324
commit
6f0202719d
@ -2,17 +2,15 @@
|
|||||||
//
|
//
|
||||||
// Execute `rustlings hint if3` or use the `hint` watch subcommand for a hint.
|
// 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 {
|
pub fn animal_habitat(animal: &str) -> &'static str {
|
||||||
let identifier = if animal == "crab" {
|
let identifier = if animal == "crab" {
|
||||||
1
|
1
|
||||||
} else if animal == "gopher" {
|
} else if animal == "gopher" {
|
||||||
2.0
|
2
|
||||||
} else if animal == "snake" {
|
} else if animal == "snake" {
|
||||||
3
|
3
|
||||||
} else {
|
} else {
|
||||||
"Unknown"
|
4
|
||||||
};
|
};
|
||||||
|
|
||||||
// DO NOT CHANGE THIS STATEMENT BELOW
|
// DO NOT CHANGE THIS STATEMENT BELOW
|
||||||
|
|||||||
@ -13,7 +13,7 @@ fn main() {
|
|||||||
println!("Good morning!");
|
println!("Good morning!");
|
||||||
}
|
}
|
||||||
|
|
||||||
let // Finish the rest of this line like the example! Or make it be false!
|
let is_evening = true; // Finish the rest of this line like the example! Or make it be false!
|
||||||
if is_evening {
|
if is_evening {
|
||||||
println!("Good evening!");
|
println!("Good evening!");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,10 +13,14 @@
|
|||||||
//
|
//
|
||||||
// No hints this time ;)
|
// No hints this time ;)
|
||||||
|
|
||||||
// I AM NOT DONE
|
|
||||||
|
|
||||||
// Put your function here!
|
// Put your function here!
|
||||||
// fn calculate_price_of_apples {
|
fn calculate_price_of_apples(quantity: i32) -> i32 {
|
||||||
|
return if quantity <= 40 {
|
||||||
|
quantity * 2
|
||||||
|
} else {
|
||||||
|
quantity * 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Don't modify this function!
|
// Don't modify this function!
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user