File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed
Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -204,6 +204,28 @@ impl Stdin {
204204 ///
205205 /// For detailed semantics of this method, see the documentation on
206206 /// `BufRead::read_line`.
207+ ///
208+ /// # Examples
209+ ///
210+ /// ```no_run
211+ /// use std::io;
212+ ///
213+ /// let mut input = String::new();
214+ /// match io::stdin().read_line(&mut input) {
215+ /// Ok(n) => {
216+ /// println!("{} bytes read", n);
217+ /// println!("{}", input);
218+ /// }
219+ /// Err(error) => println!("error: {}", error),
220+ /// }
221+ /// ```
222+ ///
223+ /// You can run the example one of two ways:
224+ ///
225+ /// - Pipe some text to it, e.g. `printf foo | path/to/executable`
226+ /// - Give it text interactively by running the executable directly,
227+ // in which case it will wait for the Enter key to be pressed before
228+ /// continuing
207229 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
208230 pub fn read_line ( & mut self , buf : & mut String ) -> io:: Result < usize > {
209231 self . lock ( ) . read_line ( buf)
You can’t perform that action at this time.
0 commit comments