wip
This commit is contained in:
@@ -3,8 +3,6 @@
|
||||
// Execute `rustlings hint options1` or use the `hint` watch subcommand for a
|
||||
// hint.
|
||||
|
||||
// I AM NOT DONE
|
||||
|
||||
// This function returns how much icecream there is left in the fridge.
|
||||
// If it's before 10PM, there's 5 scoops left. At 10PM, someone eats it
|
||||
// all, so there'll be no more left :(
|
||||
@@ -13,7 +11,15 @@ fn maybe_icecream(time_of_day: u16) -> Option<u16> {
|
||||
// value of 0. The Option output should gracefully handle cases where
|
||||
// time_of_day > 23.
|
||||
// TODO: Complete the function body - remember to return an Option!
|
||||
???
|
||||
if time_of_day < 22 {
|
||||
return Some(5);
|
||||
}
|
||||
|
||||
if time_of_day < 24 {
|
||||
return Some(0);
|
||||
}
|
||||
|
||||
None
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -35,6 +41,6 @@ mod tests {
|
||||
// TODO: Fix this test. How do you get at the value contained in the
|
||||
// Option?
|
||||
let icecreams = maybe_icecream(12);
|
||||
assert_eq!(icecreams, 5);
|
||||
assert_eq!(icecreams.unwrap(), 5);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user