So I'm working through the rustlings course and I'm on option1 and I'm confused why I need to explicitly type return before the Some(5);
fn maybe_icecream(time_of_day: u16) -> Option<u16> {
if time_of_day < 22 {
return Some(5);
} if time_of_day > 24{
None
} else {
Some(0)
}
}
I was under the impression that returns are implicit in if/else methods. So while I solved the problem I have little understanding of why it works, I only was able to because the compiler basically told me to include the return.