about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2016-07-30 00:53:18 +0200
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2016-07-30 00:53:18 +0200
commitaad5f6f912298bd0a4cc1dea698b652f81badd29 (patch)
treefc615c6c7d09c737f75438933dc079b9917948a9
parente805cb6374550190f8b3c4582fe67ae40d5b7a16 (diff)
downloadrust-aad5f6f912298bd0a4cc1dea698b652f81badd29.tar.gz
rust-aad5f6f912298bd0a4cc1dea698b652f81badd29.zip
Add doc example for io::Stderr
-rw-r--r--src/libstd/io/stdio.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/libstd/io/stdio.rs b/src/libstd/io/stdio.rs
index c4b573db5f2..a25bc038b7b 100644
--- a/src/libstd/io/stdio.rs
+++ b/src/libstd/io/stdio.rs
@@ -505,6 +505,21 @@ impl Stderr {
     ///
     /// 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 stderr = io::stderr();
+    ///     let mut handle = stderr.lock();
+    ///
+    ///     try!(handle.write(b"hello world"));
+    ///
+    ///     Ok(())
+    /// }
+    /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
     pub fn lock(&self) -> StderrLock {
         StderrLock { inner: self.inner.lock().unwrap_or_else(|e| e.into_inner()) }