Skip to content

Commit 496f547

Browse files
committed
Add documentation about panicking Add<Duration> impls
1 parent 018f8a0 commit 496f547

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/libstd/time.rs

+12
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,12 @@ impl Instant {
230230
impl Add<Duration> for Instant {
231231
type Output = Instant;
232232

233+
/// # Panics
234+
///
235+
/// This function may panic if the resulting point in time cannot be represented by the
236+
/// underlying data structure. See [`checked_add`] for a version without panic.
237+
///
238+
/// [`checked_add`]: ../../std/time/struct.Instant.html#method.checked_add
233239
fn add(self, other: Duration) -> Instant {
234240
self.checked_add(other)
235241
.expect("overflow when adding duration to instant")
@@ -397,6 +403,12 @@ impl SystemTime {
397403
impl Add<Duration> for SystemTime {
398404
type Output = SystemTime;
399405

406+
/// # Panics
407+
///
408+
/// This function may panic if the resulting point in time cannot be represented by the
409+
/// underlying data structure. See [`checked_add`] for a version without panic.
410+
///
411+
/// [`checked_add`]: ../../std/time/struct.SystemTime.html#method.checked_add
400412
fn add(self, dur: Duration) -> SystemTime {
401413
self.checked_add(dur)
402414
.expect("overflow when adding duration to instant")

0 commit comments

Comments
 (0)