-
Notifications
You must be signed in to change notification settings - Fork 533
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
0.5: Convert API to return Result
: naive
module
#1445
Conversation
As I see it there are two ways to go about converting the API to return Option 1: Convert many function signatures first, do any necessary refactorings, code changes, and documentation later. I have a preference for option 2, for a couple of reasons.
As you may have noticed I already started working in the pattern of option 2.
They can if you use adapters to convert from
That is why I gave the suggention in #1444 (comment):
The trouble is that I have a bit of a dependency tree in my mind to split up the work or to bring up tricky area's for discussion, but that is not all written down yet. I'll do some of that today. I hope this doesn't discourage you. If it is any consolation: I already tried converting most methods in the |
Especially for this commit the documentation changes are reliant on the signature change, so Option 2 seems not to be a viable option.
As mentioned,
That is not addressing the problem. I cannot change the signature of an implementation without changing the signature of the trait. Whether or not The pure API changes are roughly +100/- 100. The documentation change per function is about +120/-200 per function. There are only 4 (7) functions affected by that commit.
I can help with converting the signature, adapting the tests and improving the documentation. But functional refactoring is beyond my current level of time commitment. Core contributors have a better global understanding of the targeted behaviour which I have not. My personal stance is that the signature changes facilitate the refactoring due to more verbose error handling and better accessibility. I will finish this commit with the doc changes for |
I now see what you mean. It is blowing up at the moment because I also changed Doesn't mean I have any idea how to get around |
The issue is that I hoped to do this slow but right, instead of clearing the bar 'it compiles', and fix later.
It is viable 😄. For the methods in the
True. That is why I suggested not touching the trait in this PR yet, and wait a bit.
I am glad with your help, and hope to do the preparations myself. Once a new area is ready to convert we can divide up the work depending on your time. |
Rather than replacing It still touches the Datelike trait unfortunately. I can wait until this is addressed first, but this seems like a good compromise and supports the efforts targeted in #1050 (besides dropping the trait). |
@Zomtir No need to hurry. But as I saw you closed this PR... How are you doing? |
@pitdicker Slight progress visible here: https://github.com/Zomtir/chrono/tree/with_year I'm trying to be exact with the return types in the documentation, but an exhaustive list of error will produce quite a lot of duplicated information. I'm trying to document the important nodes (and their errors) in the call chain and reference them from the callers instead. The All in all, not yet ready for review sadly. |
May I suggest the following methods as a first step, hopefully spread over multiple PRs?
They should be easier to convert, and be a good basis for the rest of the work. |
Especially |
I looked at a few of those: Dependency of
Dependency of
I guess the best would be to start with |
#1460 takes care of Edit: Want to do |
|
Not yet 😄. |
Yes, What is the procedure for commits that depend on pending merges? I based my branch on your d60fbaf, so those would show up in the pull request against 0.5.x. |
Ctrl-F |
Just yesterday I did |
Usually I have a queue of branches ready to open as a PR once the work it builds on is merged 😆. |
Follow up commit for #1444.
NaiveDate
,NaiveTime
andNaiveDateTime
to returnResult
Datelike
andTimelike
traits to returnResult
DateTime<Tz>
has to returnResult
as wellDoc and tests still WIP.
Feedback from @pitdicker
Do smaller commits have to compile? Currently this is a minimum patch to be able to compile.
DateTime
implements theDatelike
andTimelike
traits. Doesn't this mean I have to change all classes that implement that trait? Please call me out on that if I am wrong.If I ignore
map_local
, the call stack would beResult<Datelike>
->Option<Datelike>
->Result<Datelike>
. This will hide the error and not propagate the earlier one. The only solution I came up with was to adaptmap_local
to pass the error asResult
.The consequence was that all functions that make use of
map_local
would need to propagate aResult
.This commit covers quite a lot of the changes mentioned in #1050. Wouldn't this patch be the perfect groundwork for #1050? The commits do not really conflict and this patch only retains current behaviour.