We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent aad5f6f commit 451683fCopy full SHA for 451683f
src/libstd/io/stdio.rs
@@ -240,6 +240,21 @@ impl Stdin {
240
///
241
/// [`Read`]: trait.Read.html
242
/// [`BufRead`]: trait.BufRead.html
243
+ ///
244
+ /// # Examples
245
246
+ /// ```
247
+ /// use std::io::{self, Read};
248
249
+ /// # fn foo() -> io::Result<String> {
250
+ /// let mut buffer = String::new();
251
+ /// let stdin = io::stdin();
252
+ /// let mut handle = stdin.lock();
253
254
+ /// try!(handle.read_to_string(&mut buffer));
255
+ /// # Ok(buffer)
256
+ /// # }
257
258
#[stable(feature = "rust1", since = "1.0.0")]
259
pub fn lock(&self) -> StdinLock {
260
StdinLock { inner: self.inner.lock().unwrap_or_else(|e| e.into_inner()) }
0 commit comments