Skip to content

Commit

Permalink
Replace read_to_string with read_line in Stdin example
Browse files Browse the repository at this point in the history
  • Loading branch information
elichai committed Aug 6, 2021
1 parent 4c29cc8 commit 4763ef2
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions library/std/src/io/stdio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,12 +216,12 @@ fn handle_ebadf<T>(r: io::Result<T>, default: T) -> io::Result<T> {
/// # Examples
///
/// ```no_run
/// use std::io::{self, Read};
/// use std::io;
///
/// fn main() -> io::Result<()> {
/// let mut buffer = String::new();
/// let mut stdin = io::stdin(); // We get `Stdin` here.
/// stdin.read_to_string(&mut buffer)?;
/// stdin.read_line(&mut buffer)?;
/// Ok(())
/// }
/// ```
Expand All @@ -244,14 +244,14 @@ pub struct Stdin {
/// # Examples
///
/// ```no_run
/// use std::io::{self, Read};
/// use std::io::{self, BufRead};
///
/// fn main() -> io::Result<()> {
/// let mut buffer = String::new();
/// let stdin = io::stdin(); // We get `Stdin` here.
/// {
/// let mut handle = stdin.lock(); // We get `StdinLock` here.
/// handle.read_to_string(&mut buffer)?;
/// handle.read_line(&mut buffer)?;
/// } // `StdinLock` is dropped here.
/// Ok(())
/// }
Expand All @@ -277,26 +277,26 @@ pub struct StdinLock<'a> {
/// Using implicit synchronization:
///
/// ```no_run
/// use std::io::{self, Read};
/// use std::io;
///
/// fn main() -> io::Result<()> {
/// let mut buffer = String::new();
/// io::stdin().read_to_string(&mut buffer)?;
/// io::stdin().read_line(&mut buffer)?;
/// Ok(())
/// }
/// ```
///
/// Using explicit synchronization:
///
/// ```no_run
/// use std::io::{self, Read};
/// use std::io::{self, BufRead};
///
/// fn main() -> io::Result<()> {
/// let mut buffer = String::new();
/// let stdin = io::stdin();
/// let mut handle = stdin.lock();
///
/// handle.read_to_string(&mut buffer)?;
/// handle.read_line(&mut buffer)?;
/// Ok(())
/// }
/// ```
Expand Down Expand Up @@ -337,13 +337,13 @@ pub fn stdin() -> Stdin {
///
/// ```no_run
/// #![feature(stdio_locked)]
/// use std::io::{self, Read};
/// use std::io::{self, BufRead};
///
/// fn main() -> io::Result<()> {
/// let mut buffer = String::new();
/// let mut handle = io::stdin_locked();
///
/// handle.read_to_string(&mut buffer)?;
/// handle.read_line(&mut buffer)?;
/// Ok(())
/// }
/// ```
Expand All @@ -363,14 +363,14 @@ impl Stdin {
/// # Examples
///
/// ```no_run
/// use std::io::{self, Read};
/// use std::io::{self, BufRead};
///
/// fn main() -> io::Result<()> {
/// let mut buffer = String::new();
/// let stdin = io::stdin();
/// let mut handle = stdin.lock();
///
/// handle.read_to_string(&mut buffer)?;
/// handle.read_line(&mut buffer)?;
/// Ok(())
/// }
/// ```
Expand Down Expand Up @@ -432,13 +432,13 @@ impl Stdin {
///
/// ```no_run
/// #![feature(stdio_locked)]
/// use std::io::{self, Read};
/// use std::io::{self, BufRead};
///
/// fn main() -> io::Result<()> {
/// let mut buffer = String::new();
/// let mut handle = io::stdin().into_locked();
///
/// handle.read_to_string(&mut buffer)?;
/// handle.read_line(&mut buffer)?;
/// Ok(())
/// }
/// ```
Expand Down

0 comments on commit 4763ef2

Please sign in to comment.