File tree 1 file changed +6
-8
lines changed
1 file changed +6
-8
lines changed Original file line number Diff line number Diff line change 145
145
//! # }
146
146
//! ```
147
147
//!
148
- //! Note that you cannot use the `?` operator in functions that do not return a `Result<T, E>` (e.g. `main`).
149
- //! Instead, you can `match` on the return value to catch any possible errors:
150
- //!
148
+ //! Note that you cannot use the `?` operator in functions that do not return
149
+ //! a `Result<T, E>` (e.g. `main`). Instead, you can call `.unwrap()` or `match`
150
+ //! on the return value to catch any possible errors:
151
+ //!
151
152
//! ```
152
153
//! let mut input = String::new();
153
- //!
154
- //! match io::stdin().read_line(&mut input) {
155
- //! Err(why) => panic!("Failed to read input: {}", why.description()),
156
- //! Ok(_) => println!("You typed: {}", input.trim()),
157
- //! }
154
+ //!
155
+ //! io::stdin().read_line(&mut input).unwrap();
158
156
//! ```
159
157
//!
160
158
//! And a very common source of output is standard output:
You can’t perform that action at this time.
0 commit comments