Skip to content

Commit f8fc436

Browse files
Changed unwrap_or to unwrap_or_else in some places.
The discussion seems to have resolved that this lint is a bit "noisy" in that applying it in all places would result in a reduction in readability. A few of the trivial functions (like `Path::new`) are fine to leave outside of closures. The general rule seems to be that anything that is obviously an allocation (`Box`, `Vec`, `vec![]`) should be in a closure, even if it is a 0-sized allocation.
1 parent 01ef20e commit f8fc436

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

std/src/time.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ impl Instant {
322322
/// ```
323323
#[stable(feature = "checked_duration_since", since = "1.39.0")]
324324
pub fn saturating_duration_since(&self, earlier: Instant) -> Duration {
325-
self.checked_duration_since(earlier).unwrap_or(Duration::new(0, 0))
325+
self.checked_duration_since(earlier).unwrap_or_default()
326326
}
327327

328328
/// Returns the amount of time elapsed since this instant was created.

0 commit comments

Comments
 (0)