about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2016-07-30 00:56:14 +0200
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2016-07-30 00:56:14 +0200
commit451683f0eec360bf4adbec5c19be764b7fac79e4 (patch)
tree59aec231400be09f7438e850132ddcc01026e923 /src
parentaad5f6f912298bd0a4cc1dea698b652f81badd29 (diff)
downloadrust-451683f0eec360bf4adbec5c19be764b7fac79e4.tar.gz
rust-451683f0eec360bf4adbec5c19be764b7fac79e4.zip
Add doc example for Stdin
Diffstat (limited to 'src')
-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 a25bc038b7b..d7566d5c9a4 100644
--- a/src/libstd/io/stdio.rs
+++ b/src/libstd/io/stdio.rs
@@ -240,6 +240,21 @@ impl Stdin {
     ///
     /// [`Read`]: trait.Read.html
     /// [`BufRead`]: trait.BufRead.html
+    ///
+    /// # Examples
+    ///
+    /// ```
+    /// use std::io::{self, Read};
+    ///
+    /// # fn foo() -> io::Result<String> {
+    /// let mut buffer = String::new();
+    /// let stdin = io::stdin();
+    /// let mut handle = stdin.lock();
+    ///
+    /// try!(handle.read_to_string(&mut buffer));
+    /// # Ok(buffer)
+    /// # }
+    /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
     pub fn lock(&self) -> StdinLock {
         StdinLock { inner: self.inner.lock().unwrap_or_else(|e| e.into_inner()) }