Skip to content

Commit

Permalink
Add helpful hint on io function for beginners
Browse files Browse the repository at this point in the history
  • Loading branch information
pirate committed Mar 23, 2017
1 parent d558037 commit 4dc1225
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/libstd/io/mod.rs
Expand Up @@ -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:
//!
Expand Down

0 comments on commit 4dc1225

Please sign in to comment.