Skip to content

Commit aeb3af8

Browse files
Add doc example for Stdout
1 parent 451683f commit aeb3af8

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/libstd/io/stdio.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,21 @@ impl Stdout {
414414
///
415415
/// The lock is released when the returned lock goes out of scope. The
416416
/// returned guard also implements the `Write` trait for writing data.
417+
///
418+
/// # Examples
419+
///
420+
/// ```
421+
/// use std::io::{self, Write};
422+
///
423+
/// # fn foo() -> io::Result<()> {
424+
/// let stdout = io::stdout();
425+
/// let mut handle = stdout.lock();
426+
///
427+
/// try!(handle.write(b"hello world"));
428+
///
429+
/// # Ok(())
430+
/// # }
431+
/// ```
417432
#[stable(feature = "rust1", since = "1.0.0")]
418433
pub fn lock(&self) -> StdoutLock {
419434
StdoutLock { inner: self.inner.lock().unwrap_or_else(|e| e.into_inner()) }

0 commit comments

Comments
 (0)