From: Nick Sweeting Date: Mon, 27 Mar 2017 20:34:13 +0000 (-0400) Subject: Fix tidy errors and simplify example X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=4806f01d7c1f35a1b6f675ff099b86ec6e6c1540;p=rust.git Fix tidy errors and simplify example --- diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index 773b0964b42..1b0c992ba09 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -145,16 +145,14 @@ //! # } //! ``` //! -//! Note that you cannot use the `?` operator in functions that do not return a `Result` (e.g. `main`). -//! Instead, you can `match` on the return value to catch any possible errors: -//! +//! Note that you cannot use the `?` operator in functions that do not return +//! a `Result` (e.g. `main`). Instead, you can call `.unwrap()` or `match` +//! on the return value to catch any possible errors: +//! //! ``` //! let mut input = String::new(); -//! -//! match io::stdin().read_line(&mut input) { -//! Err(why) => panic!("Failed to read input: {}", why.description()), -//! Ok(_) => println!("You typed: {}", input.trim()), -//! } +//! +//! io::stdin().read_line(&mut input).unwrap(); //! ``` //! //! And a very common source of output is standard output: