diff options
| author | bors <bors@rust-lang.org> | 2016-03-24 09:25:02 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2016-03-24 09:25:02 -0700 |
| commit | dcfb8d72e99425686376298fd793715f35b5d512 (patch) | |
| tree | a202c287d30ee142f1931f5dd02bee256324d7e7 /src/libstd | |
| parent | dc1f6831eb0d0e5cca16395f14b7406ff85c4c3d (diff) | |
| parent | b2dfb7c0a267d6f2adb9cbde1e157fc136fcaaab (diff) | |
| download | rust-dcfb8d72e99425686376298fd793715f35b5d512.tar.gz rust-dcfb8d72e99425686376298fd793715f35b5d512.zip | |
Auto merge of #32465 - steveklabnik:rollup, r=steveklabnik
Rollup of 6 pull requests - Successful merges: #32276, #32416, #32452, #32459, #32462, #32464 - Failed merges:
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/io/stdio.rs | 4 | ||||
| -rw-r--r-- | src/libstd/time/mod.rs | 50 |
2 files changed, 52 insertions, 2 deletions
diff --git a/src/libstd/io/stdio.rs b/src/libstd/io/stdio.rs index e1a388c38c4..c4b573db5f2 100644 --- a/src/libstd/io/stdio.rs +++ b/src/libstd/io/stdio.rs @@ -141,8 +141,8 @@ fn handle_ebadf<T>(r: io::Result<T>, default: T) -> io::Result<T> { /// /// Each handle is a shared reference to a global buffer of input data to this /// process. A handle can be `lock`'d to gain full access to [`BufRead`] methods -/// (e.g. `.lines()`). Writes to this handle are otherwise locked with respect -/// to other writes. +/// (e.g. `.lines()`). Reads to this handle are otherwise locked with respect +/// to other reads. /// /// This handle implements the `Read` trait, but beware that concurrent reads /// of `Stdin` must be executed with care. diff --git a/src/libstd/time/mod.rs b/src/libstd/time/mod.rs index aa0a843dc9a..0c32feebecb 100644 --- a/src/libstd/time/mod.rs +++ b/src/libstd/time/mod.rs @@ -9,6 +9,16 @@ // except according to those terms. //! Temporal quantification. +//! +//! Example: +//! +//! ``` +//! use std::time::Duration; +//! +//! let five_seconds = Duration::new(5, 0); +//! // both declarations are equivalent +//! assert_eq!(Duration::new(5, 0), Duration::from_secs(5)); +//! ``` #![stable(feature = "time", since = "1.3.0")] @@ -40,6 +50,22 @@ mod duration; /// no method to get "the number of seconds" from an instant. Instead, it only /// allows measuring the duration between two instants (or comparing two /// instants). +/// +/// Example: +/// +/// ```no_run +/// use std::time::{Duration, Instant}; +/// use std::thread::sleep; +/// +/// fn main() { +/// let now = Instant::now(); +/// +/// // we sleep for 2 seconds +/// sleep(Duration::new(2, 0)); +/// // it prints '2' +/// println!("{}", now.elapsed().as_secs()); +/// } +/// ``` #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord)] #[stable(feature = "time2", since = "1.8.0")] pub struct Instant(time::Instant); @@ -63,6 +89,30 @@ pub struct Instant(time::Instant); /// information about a `SystemTime`. By calculating the duration from this /// fixed point in time, a `SystemTime` can be converted to a human-readable time, /// or perhaps some other string representation. +/// +/// Example: +/// +/// ```no_run +/// use std::time::{Duration, SystemTime}; +/// use std::thread::sleep; +/// +/// fn main() { +/// let now = SystemTime::now(); +/// +/// // we sleep for 2 seconds +/// sleep(Duration::new(2, 0)); +/// match now.elapsed() { +/// Ok(elapsed) => { +/// // it prints '2' +/// println!("{}", elapsed.as_secs()); +/// } +/// Err(e) => { +/// // an error occured! +/// println!("Error: {:?}", e); +/// } +/// } +/// } +/// ``` #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord)] #[stable(feature = "time2", since = "1.8.0")] pub struct SystemTime(time::SystemTime); |
