diff --git a/exercises/options/options1.rs b/exercises/options/options1.rs index 1f891b0e..7dd42213 100644 --- a/exercises/options/options1.rs +++ b/exercises/options/options1.rs @@ -9,8 +9,13 @@ fn maybe_icecream(time_of_day: u16) -> Option { // 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); } } diff --git a/temp_8445_ThreadId1 b/temp_8445_ThreadId1 new file mode 100755 index 00000000..ae8e7992 Binary files /dev/null and b/temp_8445_ThreadId1 differ