You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
rustlings/excercises/options/options1.rs invites to use the Option types to manage the return value of a function that checks whether there's icecream or not.
Both scenarios where there's a known amount of icecream are expected to be Some values, and the excercise asks to "gracefully handle values where the hour of the day is larger than 23". Sure, using a None is a possibility, but another one is to just time_of_day % 24, specially in the context of the comment:
// 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.
Which I think sounds more biased towards the modulo solution than the behaviour expected from the tests. Maybe some kind of rephrasing as to what is understood as "graceful" could be more leading as to why we are using an Option as return type here. Is the function only supposed to work today?
Will the ice-cream be automatically replenished every day at zero hours? I think both of this statements are equally funny and far-fetched, and nothing points clearly towards it being the former and not the latter that is true.
The text was updated successfully, but these errors were encountered:
Right, I agree that the comment could be rephrased to explain that if time_of_day = 493, that's an invalid state, and that we want to handle that gracefully by returning None. If someone wants to go for a PR, I'll happily merge it, otherwise I'll get to it at some point 👍
rustlings/excercises/options/options1.rs
invites to use the Option types to manage the return value of a function that checks whether there's icecream or not.Both scenarios where there's a known amount of icecream are expected to be
Some
values, and the excercise asks to "gracefully handle values where the hour of the day is larger than 23". Sure, using aNone
is a possibility, but another one is to justtime_of_day % 24
, specially in the context of the comment:Which I think sounds more biased towards the modulo solution than the behaviour expected from the tests. Maybe some kind of rephrasing as to what is understood as "graceful" could be more leading as to why we are using an Option as return type here. Is the function only supposed to work today?
Will the ice-cream be automatically replenished every day at zero hours? I think both of this statements are equally funny and far-fetched, and nothing points clearly towards it being the former and not the latter that is true.
The text was updated successfully, but these errors were encountered: