diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2016-07-30 00:57:20 +0200 |
|---|---|---|
| committer | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2016-07-30 00:57:20 +0200 |
| commit | aeb3af898ae426031376a345f91e04bfc7af32f8 (patch) | |
| tree | 27c85ffb29f9fe4c5c386970f13c25dccc01fe40 /src/libstd | |
| parent | 451683f0eec360bf4adbec5c19be764b7fac79e4 (diff) | |
| download | rust-aeb3af898ae426031376a345f91e04bfc7af32f8.tar.gz rust-aeb3af898ae426031376a345f91e04bfc7af32f8.zip | |
Add doc example for Stdout
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/io/stdio.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/libstd/io/stdio.rs b/src/libstd/io/stdio.rs index d7566d5c9a4..b8b66a58359 100644 --- a/src/libstd/io/stdio.rs +++ b/src/libstd/io/stdio.rs @@ -414,6 +414,21 @@ impl Stdout { /// /// The lock is released when the returned lock goes out of scope. The /// returned guard also implements the `Write` trait for writing data. + /// + /// # Examples + /// + /// ``` + /// use std::io::{self, Write}; + /// + /// # fn foo() -> io::Result<()> { + /// let stdout = io::stdout(); + /// let mut handle = stdout.lock(); + /// + /// try!(handle.write(b"hello world")); + /// + /// # Ok(()) + /// # } + /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn lock(&self) -> StdoutLock { StdoutLock { inner: self.inner.lock().unwrap_or_else(|e| e.into_inner()) } |
