Add helpful hint on io function for beginners

This commit is contained in:
Nick Sweeting 2017-03-23 13:17:21 -04:00 committed by GitHub
parent d5580374d7
commit 4dc1225807

View File

@ -144,6 +144,16 @@
//! # Ok(())
//! # }
//! ```
//! 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:
//!
//! ```
//! 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()),
//! }
//! ```
//!
//! And a very common source of output is standard output:
//!