about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-06-30 23:46:57 +0000
committerbors <bors@rust-lang.org>2015-06-30 23:46:57 +0000
commitbf3c979ec31300e38c1607d605cf47f231bf6480 (patch)
tree7f6589cb3d62ea6313d1e43c22ba0f55fabe37d1 /src/libstd
parentdc309d79e9cbe473d68ad1292f5df73000a22891 (diff)
parent08f9b98e57f2332da522ebf98c74a315211b98ac (diff)
downloadrust-bf3c979ec31300e38c1607d605cf47f231bf6480.tar.gz
rust-bf3c979ec31300e38c1607d605cf47f231bf6480.zip
Auto merge of #26696 - steveklabnik:rollup, r=steveklabnik
- Successful merges: #26373, #26506, #26580, #26622, #26627, #26651, #26678, #26692
- Failed merges: 
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/io/stdio.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/libstd/io/stdio.rs b/src/libstd/io/stdio.rs
index 9fd48f67950..2a64d0f6e8c 100644
--- a/src/libstd/io/stdio.rs
+++ b/src/libstd/io/stdio.rs
@@ -204,6 +204,28 @@ impl Stdin {
     ///
     /// For detailed semantics of this method, see the documentation on
     /// `BufRead::read_line`.
+    ///
+    /// # Examples
+    ///
+    /// ```no_run
+    /// use std::io;
+    ///
+    /// let mut input = String::new();
+    /// match io::stdin().read_line(&mut input) {
+    ///     Ok(n) => {
+    ///         println!("{} bytes read", n);
+    ///         println!("{}", input);
+    ///     }
+    ///     Err(error) => println!("error: {}", error),
+    /// }
+    /// ```
+    ///
+    /// You can run the example one of two ways:
+    ///
+    /// - Pipe some text to it, e.g. `printf foo | path/to/executable`
+    /// - Give it text interactively by running the executable directly,
+    //    in which case it will wait for the Enter key to be pressed before
+    ///   continuing
     #[stable(feature = "rust1", since = "1.0.0")]
     pub fn read_line(&mut self, buf: &mut String) -> io::Result<usize> {
         self.lock().read_line(buf)