Skip to content

Commit

Permalink
Suggest less bug-prone construction of Duration in docs
Browse files Browse the repository at this point in the history
  • Loading branch information
BenWiederhake committed Dec 23, 2023
1 parent c03d978 commit 7f8264b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions library/core/src/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,11 @@ impl Duration {

/// Creates a new `Duration` from the specified number of nanoseconds.
///
/// Note: Using this on the return value of `as_nanos()` might cause unexpected
/// behavior: `as_nanos()` returns a u128, and can return values that do not
/// fit in u64, e.g. 585 years. Instead, consider using the pattern
/// `Duration::new(d.as_secs(), d.subsecs_nanos())`.
///
/// # Examples
///
/// ```
Expand Down

0 comments on commit 7f8264b

Please sign in to comment.