From 1da0f56d76e5d5117eac05af092bf0ab58b14c8f Mon Sep 17 00:00:00 2001 From: Hunter Kvalevog Date: Sun, 27 Sep 2026 11:17:50 -0500 Subject: rustlings: complete 12 --- rustlings/exercises/12_options/options1.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'rustlings/exercises/12_options/options1.rs') diff --git a/rustlings/exercises/12_options/options1.rs b/rustlings/exercises/12_options/options1.rs index d0c412a..be97952 100644 --- a/rustlings/exercises/12_options/options1.rs +++ b/rustlings/exercises/12_options/options1.rs @@ -3,7 +3,13 @@ // someone eats it all, so no ice cream is left (value 0). Return `None` if // `hour_of_day` is higher than 23. fn maybe_ice_cream(hour_of_day: u16) -> Option { - // TODO: Complete the function body. + if hour_of_day >= 24 { + return None; + } + if hour_of_day >= 22 { + return Some(0); + } + Some(5) } fn main() { @@ -18,7 +24,7 @@ mod tests { fn raw_value() { // TODO: Fix this test. How do you get the value contained in the // Option? - let ice_creams = maybe_ice_cream(12); + let ice_creams = maybe_ice_cream(12).unwrap(); assert_eq!(ice_creams, 5); // Don't change this line. } -- cgit v1.2.3