diff --git a/exercises/options/options1.rs b/exercises/options/options1.rs index 6c83c1192b..cf4002beb5 100644 --- a/exercises/options/options1.rs +++ b/exercises/options/options1.rs @@ -7,12 +7,12 @@ 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. - if time_of_day <= 10 { + if time_of_day > 23 { + None + } else if time_of_day < 22 { Some(5) - } else if time_of_day <= 23 { - Some(0) } else { - None + Some(0) } } @@ -32,7 +32,11 @@ 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, Some(0)); + let result = maybe_icecream(12); + + match result { + Some(icecreams) => assert_eq!(icecreams, 5), + None => println!("Err"), + } } }