diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2016-07-30 00:56:14 +0200 |
|---|---|---|
| committer | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2016-07-30 00:56:14 +0200 |
| commit | 451683f0eec360bf4adbec5c19be764b7fac79e4 (patch) | |
| tree | 59aec231400be09f7438e850132ddcc01026e923 /src/libstd/io | |
| parent | aad5f6f912298bd0a4cc1dea698b652f81badd29 (diff) | |
| download | rust-451683f0eec360bf4adbec5c19be764b7fac79e4.tar.gz rust-451683f0eec360bf4adbec5c19be764b7fac79e4.zip | |
Add doc example for Stdin
Diffstat (limited to 'src/libstd/io')
| -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 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()) } |
