Skip to content

Commit

Permalink
Simplify lambdas
Browse files Browse the repository at this point in the history
  • Loading branch information
faern committed Jan 31, 2019
1 parent f841ff4 commit 2f2d495
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/libstd/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,15 +247,15 @@ impl Instant {
/// otherwise.
#[stable(feature = "time_checked_add", since = "1.34.0")]
pub fn checked_add(&self, duration: Duration) -> Option<Instant> {
self.0.checked_add_duration(&duration).map(|t| Instant(t))
self.0.checked_add_duration(&duration).map(Instant)
}

/// Returns `Some(t)` where `t` is the time `self - duration` if `t` can be represented as
/// `Instant` (which means it's inside the bounds of the underlying data structure), `None`
/// otherwise.
#[stable(feature = "time_checked_add", since = "1.34.0")]
pub fn checked_sub(&self, duration: Duration) -> Option<Instant> {
self.0.checked_sub_duration(&duration).map(|t| Instant(t))
self.0.checked_sub_duration(&duration).map(Instant)
}
}

Expand Down Expand Up @@ -420,15 +420,15 @@ impl SystemTime {
/// otherwise.
#[stable(feature = "time_checked_add", since = "1.34.0")]
pub fn checked_add(&self, duration: Duration) -> Option<SystemTime> {
self.0.checked_add_duration(&duration).map(|t| SystemTime(t))
self.0.checked_add_duration(&duration).map(SystemTime)
}

/// Returns `Some(t)` where `t` is the time `self - duration` if `t` can be represented as
/// `SystemTime` (which means it's inside the bounds of the underlying data structure), `None`
/// otherwise.
#[stable(feature = "time_checked_add", since = "1.34.0")]
pub fn checked_sub(&self, duration: Duration) -> Option<SystemTime> {
self.0.checked_sub_duration(&duration).map(|t| SystemTime(t))
self.0.checked_sub_duration(&duration).map(SystemTime)
}
}

Expand Down

0 comments on commit 2f2d495

Please sign in to comment.