-
Notifications
You must be signed in to change notification settings - Fork 195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fallback values for datetime errors #4851
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realized that it will be easier to review if I just download the code and make inline edits. I will push my suggestions to your branch.
ds.get_symbol_for_era(l, &year.era) | ||
.map(|e| e.unwrap_or(&year.era.0)) | ||
}) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: I think you don't need the extra map
here. It should use the Err
path in the match
ds.get_symbol_for_era(l, &year.era) | |
.map(|e| e.unwrap_or(&year.era.0)) | |
}) { | |
ds.get_symbol_for_era(l, &year.era) | |
}) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get_symbol_for_era
returns Result<Option<&str>>
, so I was under the impression that the Option
is an optimisation and not an error. If it's an error, why doesn't it return Result<&str>
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See the test I had to change. It was a mechanism to write out the era name fallback. TryWriteable is a better solution. Hmm, I think this trait is internal, so we could probably change it to return Result<&str>
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will address this in a follow-up
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I approve with the additional changes I pushed to your branch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will wait for @robertbastian to review my changes and merge.
ds.get_symbol_for_era(l, &year.era) | ||
.map(|e| e.unwrap_or(&year.era.0)) | ||
}) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get_symbol_for_era
returns Result<Option<&str>>
, so I was under the impression that the Option
is an optimisation and not an error. If it's an error, why doesn't it return Result<&str>
?
.and_then(|ns| { | ||
// We only support fixed field length for fractional seconds. | ||
let FieldLength::Fixed(p) = length else { | ||
return Err(Error::Pattern( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Avoid using return
in this function. Unclear what it returns from
No description provided.