From a4b29a54b8fbf6746b19b83f2284a2946cd2aa8d Mon Sep 17 00:00:00 2001 From: fxbtr <41640867+fxbtr@users.noreply.github.com> Date: Mon, 8 May 2023 00:28:18 +0200 Subject: [PATCH 1/2] fix(options1): uses 24h system as requested --- exercises/options/options1.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/exercises/options/options1.rs b/exercises/options/options1.rs index 6c83c1192b..368ba8533b 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) } } @@ -33,6 +33,6 @@ mod tests { 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)); + assert_eq!(icecreams, Some(5)); } } From 7a0641de8102c89eac2f539473e3dd1bb7b88b91 Mon Sep 17 00:00:00 2001 From: fxbtr <41640867+fxbtr@users.noreply.github.com> Date: Mon, 8 May 2023 00:37:17 +0200 Subject: [PATCH 2/2] fix(options1): get at value in Opt., as requested --- exercises/options/options1.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/exercises/options/options1.rs b/exercises/options/options1.rs index 368ba8533b..cf4002beb5 100644 --- a/exercises/options/options1.rs +++ b/exercises/options/options1.rs @@ -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(5)); + let result = maybe_icecream(12); + + match result { + Some(icecreams) => assert_eq!(icecreams, 5), + None => println!("Err"), + } } }