We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 26315bf + 102b3a9 commit 30198bfCopy full SHA for 30198bf
src/libstd/time/mod.rs
@@ -150,6 +150,18 @@ impl Instant {
150
/// This function may panic if the current time is earlier than this
151
/// instant, which is something that can happen if an `Instant` is
152
/// produced synthetically.
153
+ ///
154
+ /// # Examples
155
156
+ /// ```no_run
157
+ /// use std::thread::sleep;
158
+ /// use std::time::{Duration, Instant};
159
160
+ /// let instant = Instant::now();
161
+ /// let three_secs = Duration::from_secs(3);
162
+ /// sleep(three_secs);
163
+ /// assert!(instant.elapsed() >= three_secs);
164
+ /// ```
165
#[stable(feature = "time2", since = "1.8.0")]
166
pub fn elapsed(&self) -> Duration {
167
Instant::now() - *self
0 commit comments