diff --git a/exercises/12_options/options1.rs b/exercises/12_options/options1.rs index e131b48b..5338b929 100644 --- a/exercises/12_options/options1.rs +++ b/exercises/12_options/options1.rs @@ -13,7 +13,13 @@ fn maybe_icecream(time_of_day: u16) -> Option { // 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 && time_of_day <= 24 { + return Some(0); + } else if time_of_day >= 24 { + return None; + } + + Option::Some(5) } #[cfg(test)] @@ -34,6 +40,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, Some(5)); } }