Skip to content

Commit 0df7f93

Browse files
authored
Use a u128 example time.rs
Earlier for the example I used 2.pow(64). correcting it to use u128 type which can contain the value
1 parent d2e35d8 commit 0df7f93

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

library/core/src/time.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,10 +321,12 @@ impl Duration {
321321
/// ```
322322
/// #![feature(duration_from_nanos_u128)]
323323
/// use std::time::Duration;
324-
/// let time_in_nanos = 2.pow(64);
324+
/// let time_in_nanos = 2u128.pow(64);
325325
/// let duration = Duration::from_nanos_u128(time_in_nanos);
326326
/// ```
327327
#[unstable(feature = "duration_from_nanos_u128", issue = "139201")]
328+
#[must_use]
329+
#[inline]
328330
pub const fn from_nanos_u128(nanos: u128) -> Duration {
329331
const NANOS_PER_SEC: u128 = self::NANOS_PER_SEC as u128;
330332
let secs : u64 = (nanos/ NANOS_PER_SEC) as u64 ;

0 commit comments

Comments
 (0)