@@ -218,9 +218,23 @@ fn handle_ebadf<T>(r: io::Result<T>, default: T) -> io::Result<T> {
218218/// [`BufRead`]: trait.BufRead.html
219219///
220220/// ### Note: Windows Portability Consideration
221+ ///
221222/// When operating in a console, the Windows implementation of this stream does not support
222223/// non-UTF-8 byte sequences. Attempting to read bytes that are not valid UTF-8 will return
223224/// an error.
225+ ///
226+ /// # Examples
227+ ///
228+ /// ```no_run
229+ /// use std::io::{self, Read};
230+ ///
231+ /// fn main() -> io::Result<()> {
232+ /// let mut buffer = String::new();
233+ /// let mut stdin = io::stdin(); // We get `Stdin` here.
234+ /// stdin.read_to_string(&mut buffer)?;
235+ /// Ok(())
236+ /// }
237+ /// ```
224238#[ stable( feature = "rust1" , since = "1.0.0" ) ]
225239pub struct Stdin {
226240 inner : Arc < Mutex < BufReader < Maybe < StdinRaw > > > > ,
@@ -236,9 +250,26 @@ pub struct Stdin {
236250/// [`Stdin::lock`]: struct.Stdin.html#method.lock
237251///
238252/// ### Note: Windows Portability Consideration
253+ ///
239254/// When operating in a console, the Windows implementation of this stream does not support
240255/// non-UTF-8 byte sequences. Attempting to read bytes that are not valid UTF-8 will return
241256/// an error.
257+ ///
258+ /// # Examples
259+ ///
260+ /// ```no_run
261+ /// use std::io::{self, Read};
262+ ///
263+ /// fn main() -> io::Result<()> {
264+ /// let mut buffer = String::new();
265+ /// let stdin = io::stdin(); // We get `Stdin` here.
266+ /// {
267+ /// let mut stdin_lock = stdin.lock(); // We get `StdinLock` here.
268+ /// stdin_lock.read_to_string(&mut buffer)?;
269+ /// } // `StdinLock` is dropped here.
270+ /// Ok(())
271+ /// }
272+ /// ```
242273#[ stable( feature = "rust1" , since = "1.0.0" ) ]
243274pub struct StdinLock < ' a > {
244275 inner : MutexGuard < ' a , BufReader < Maybe < StdinRaw > > > ,
0 commit comments