-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Add checked operation methods to Duration #36463
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @alexcrichton (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
Can we update the |
} | ||
} | ||
|
||
/// Checked integer multiplication. Computes `self * other`, returning |
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.
Checked duration multiplication
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.
Fixed, thanks!
@sfackler What's the best way to do that? Only catch I can see is Edit: To clarify, my question is specifically: do we care about the |
It looks like they only fail due to overflow, so you should just be able to do something like fn add(self, other: Duration) -> Duration {
self.checked_add(other).expect("overflow when adding durations")
} |
So how about this:
Are those reasonable? Or are the last two too wordy? |
Those all seem reasonable. I wouldn't worry too much about the wordyness - people hopefully shouldn't be seeing them very often :) |
Looks like doc-tests are failing. I'll get those fixed ASAP. |
Looks good to me! r=me when the tests are passing |
Doc-tests failing now because I marked the functions as unstable. Should I leave the marked as unstable and add the |
You should add the attributes in the examples. |
@bors: r+ Thanks! |
📌 Commit b6321bd has been approved by |
… r=alexcrichton Add checked operation methods to Duration Addresses rust-lang#35774.
Addresses #35774.