-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Duration doc #38346
Duration doc #38346
Conversation
22088dc
to
57353e2
Compare
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.
r=me unless you want to address my comment
/// ``` | ||
/// use std::time::Duration; | ||
/// | ||
/// let five_seconds = Duration::from_millis(5010); |
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.
This is not exactly five seconds so the variable binding name is slightly misleading. Could also just call it something generic like duration
. Not a super big deal.
@@ -136,9 +184,11 @@ impl Duration { | |||
} | |||
} | |||
|
|||
/// Checked duration subtraction. Computes `self + other`, returning `None` | |||
/// Checked `Duration` subtraction. Computes `self - other`, returning [`None`] |
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.
Glad you fixed the +
→ -
error here :)
/// Durations implement many common traits, including `Add`, `Sub`, and other | ||
/// ops traits. Currently a duration may only be inspected for its number of | ||
/// `Duration`s implement many common traits, including [`Add`], [`Sub`], and other | ||
/// [`ops`] traits. Currently a `Duration` may only be inspected for its number of |
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.
This last sentence is not true anymore – you may now do arithmetic on duration as well.
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'll remove it then.
@@ -207,9 +259,11 @@ impl Duration { | |||
} | |||
} | |||
|
|||
/// Checked duration division. Computes `self / other`, returning `None` | |||
/// Checked `Duration` division. Computes `self / other`, returning [`None`] | |||
/// if `other == 0` or the operation results in underflow or overflow. |
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.
Drive-by fix: division cannot underflow or overflow in other != Duraton::from_secs(0)
as having a negative or floaty duration is not possible.
/// Checked duration multiplication. Computes `self * other`, returning | ||
/// `None` if underflow or overflow occurred. | ||
/// Checked `Duration` multiplication. Computes `self * other`, returning | ||
/// [`None`] if underflow or overflow occurred. |
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.
Drive-by fix: multiplication cannot underflow as negative durations are impossible.
57353e2
to
60fbe7a
Compare
Updated. |
@bors r+ rollup |
📌 Commit 60fbe7a has been approved by |
…sxcv Duration doc r? @frewsxcv
…sxcv Duration doc r? @frewsxcv
⌛ Testing commit 60fbe7a with merge 47d4a02... |
💔 Test failed - auto-mac-64-opt-rustbuild |
@bors: retry |
⌛ Testing commit 60fbe7a with merge a6a4315... |
💔 Test failed - auto-mac-64-opt-rustbuild |
@bors: retry
…On Fri, Dec 16, 2016 at 7:59 AM, bors ***@***.***> wrote:
⌛️ Testing commit 60fbe7a
<60fbe7a>
with merge a6a4315
<a6a4315>
...
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#38346 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAD95G1KBFj5AOqkW6ou2LJ4Qt74WuRWks5rIrV_gaJpZM4LLtQD>
.
|
…sxcv Duration doc r? @frewsxcv
@bors retry |
@bors: retry |
…sxcv Duration doc r? @frewsxcv
Rollup of 29 pull requests - Successful merges: #37761, #38006, #38131, #38150, #38158, #38171, #38208, #38215, #38236, #38245, #38289, #38302, #38315, #38346, #38388, #38395, #38398, #38418, #38432, #38451, #38463, #38468, #38470, #38471, #38472, #38478, #38486, #38493, #38498 - Failed merges: #38271, #38483
r? @frewsxcv