]> git.lizzy.rs Git - rust.git/commitdiff
Fix tidy errors and simplify example
authorNick Sweeting <git@nicksweeting.com>
Mon, 27 Mar 2017 20:34:13 +0000 (16:34 -0400)
committerGitHub <noreply@github.com>
Mon, 27 Mar 2017 20:34:13 +0000 (16:34 -0400)
src/libstd/io/mod.rs

index 773b0964b4269d3031bb38f22b27896004929a6f..1b0c992ba0976605fa7b10e9abb7df47ad74c73b 100644 (file)
 //! # }
 //! ```
 //!
-//! Note that you cannot use the `?` operator in functions that do not return a `Result<T, E>` (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<T, E>` (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: