Skip to content

Commit 1ac6ba9

Browse files
committed
---
yaml --- r: 127815 b: refs/heads/master c: c6b02f6 h: refs/heads/master i: 127813: d2dfb4d 127811: a63e008 127807: 1465c0f v: v3
1 parent b787555 commit 1ac6ba9

File tree

2 files changed

+3
-18
lines changed

2 files changed

+3
-18
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: ee10f3501c1df04a015a5331c8343792e519c7a7
2+
refs/heads/master: c6b02f65589cd3d1e94fd585ad93a5e720789d5a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: aa98b25c4f0c10729dff37c699904ad57b8fbda8
55
refs/heads/try: d9c23fcbaea89871667272a67ecb8d3a512162f3

trunk/src/libstd/time/duration.rs

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ macro_rules! try_opt(
3939
#[deriving(PartialEq, Eq, PartialOrd, Ord)]
4040
pub struct Duration {
4141
days: i32,
42-
secs: u32,
43-
nanos: u32,
42+
secs: u32, // Always < SECS_PER_DAY
43+
nanos: u32, // Always < NANOS_PR_SECOND
4444
}
4545

4646
/// The minimum possible `Duration`.
@@ -81,18 +81,13 @@ impl Duration {
8181

8282
/// Makes a new `Duration` with given number of days.
8383
/// Equivalent to `Duration::new(days, 0, 0)`.
84-
///
85-
/// Fails when the duration is out of bounds.
8684
#[inline]
8785
pub fn days(days: i32) -> Duration {
88-
let days = days.to_i32().expect("Duration::days out of bounds");
8986
Duration { days: days, secs: 0, nanos: 0 }
9087
}
9188

9289
/// Makes a new `Duration` with given number of hours.
9390
/// Equivalent to `Duration::new(0, hours * 3600, 0)` with overflow checks.
94-
///
95-
/// Fails when the duration is out of bounds.
9691
#[inline]
9792
pub fn hours(hours: i32) -> Duration {
9893
let (days, hours) = div_mod_floor(hours, (SECS_PER_DAY / 3600));
@@ -102,8 +97,6 @@ impl Duration {
10297

10398
/// Makes a new `Duration` with given number of minutes.
10499
/// Equivalent to `Duration::new(0, mins * 60, 0)` with overflow checks.
105-
///
106-
/// Fails when the duration is out of bounds.
107100
#[inline]
108101
pub fn minutes(mins: i32) -> Duration {
109102
let (days, mins) = div_mod_floor(mins, (SECS_PER_DAY / 60));
@@ -113,8 +106,6 @@ impl Duration {
113106

114107
/// Makes a new `Duration` with given number of seconds.
115108
/// Equivalent to `Duration::new(0, secs, 0)`.
116-
///
117-
/// Fails when the duration is out of bounds.
118109
#[inline]
119110
pub fn seconds(secs: i32) -> Duration {
120111
let (days, secs) = div_mod_floor(secs, SECS_PER_DAY);
@@ -123,8 +114,6 @@ impl Duration {
123114

124115
/// Makes a new `Duration` with given number of milliseconds.
125116
/// Equivalent to `Duration::new(0, 0, millis * 1_000_000)` with overflow checks.
126-
///
127-
/// Fails when the duration is out of bounds.
128117
#[inline]
129118
pub fn milliseconds(millis: i32) -> Duration {
130119
let (secs, millis) = div_mod_floor(millis, (NANOS_PER_SEC / 1_000_000));
@@ -134,8 +123,6 @@ impl Duration {
134123

135124
/// Makes a new `Duration` with given number of microseconds.
136125
/// Equivalent to `Duration::new(0, 0, micros * 1_000)` with overflow checks.
137-
///
138-
/// Fails when the duration is out of bounds.
139126
#[inline]
140127
pub fn microseconds(micros: i32) -> Duration {
141128
let (secs, micros) = div_mod_floor(micros, (NANOS_PER_SEC / 1_000));
@@ -145,8 +132,6 @@ impl Duration {
145132

146133
/// Makes a new `Duration` with given number of nanoseconds.
147134
/// Equivalent to `Duration::new(0, 0, nanos)`.
148-
///
149-
/// Fails when the duration is out of bounds.
150135
#[inline]
151136
pub fn nanoseconds(nanos: i32) -> Duration {
152137
let (secs, nanos) = div_mod_floor(nanos, NANOS_PER_SEC);

0 commit comments

Comments
 (0)