diff options
| author | bors <bors@rust-lang.org> | 2016-09-10 07:03:27 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-09-10 07:03:27 -0700 |
| commit | f8ba7cb863bf2e5fe081d82358c7cda376a7eac6 (patch) | |
| tree | 6145c772d2eadb7594cfbc41ef9ae88faeb1194c /src/libstd/time | |
| parent | a5f4cc527de4230359c81799852f6bc770eba0e6 (diff) | |
| parent | 2ded39938ac365fc843062eeef39439429a845da (diff) | |
| download | rust-f8ba7cb863bf2e5fe081d82358c7cda376a7eac6.tar.gz rust-f8ba7cb863bf2e5fe081d82358c7cda376a7eac6.zip | |
Auto merge of #36378 - GuillaumeGomez:rollup, r=GuillaumeGomez
Rollup of 6 pull requests - Successful merges: #35691, #36045, #36311, #36314, #36326, #36346 - Failed merges:
Diffstat (limited to 'src/libstd/time')
| -rw-r--r-- | src/libstd/time/mod.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/libstd/time/mod.rs b/src/libstd/time/mod.rs index 0e1508a1c4c..154f603c84f 100644 --- a/src/libstd/time/mod.rs +++ b/src/libstd/time/mod.rs @@ -150,6 +150,18 @@ impl Instant { /// This function may panic if the current time is earlier than this /// instant, which is something that can happen if an `Instant` is /// produced synthetically. + /// + /// # Examples + /// + /// ```no_run + /// use std::thread::sleep; + /// use std::time::{Duration, Instant}; + /// + /// let instant = Instant::now(); + /// let three_secs = Duration::from_secs(3); + /// sleep(three_secs); + /// assert!(instant.elapsed() >= three_secs); + /// ``` #[stable(feature = "time2", since = "1.8.0")] pub fn elapsed(&self) -> Duration { Instant::now() - *self |
