progress 50 percent

Change-Id: Ie32fb2faa3d1290beffcc7d5c20b9ed19e141411
This commit is contained in:
murasame 2023-05-19 17:47:53 +08:00
parent 3cc91daba5
commit 031a15a317
2 changed files with 9 additions and 5 deletions

View File

@ -9,8 +9,13 @@
fn maybe_icecream(time_of_day: u16) -> Option<u16> {
// We use the 24-hour system here, so 10PM is a value of 22 and 12AM is a 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 >= 22 && time_of_day <= 24 {
return Some(0);
}
None
}
#[cfg(test)]
@ -28,8 +33,7 @@ mod tests {
#[test]
fn raw_value() {
// TODO: Fix this test. How do you get at the value contained in the Option?
let icecreams = maybe_icecream(12);
assert_eq!(icecreams, 5);
let icecreams = maybe_icecream(12).unwrap();
assert_eq!(icecreams, 5u16);
}
}

BIN
temp_8445_ThreadId1 Executable file

Binary file not shown.