Change:
showed that some people are confused by the use of the on values in the documentation. Since is now stable, this pattern has become mostly obsolete (with the exception of types whose error types do not implement , which shouldn't be very common). It probably shouldn't be used in the docs any more. Probably the most important place where this should be fixed is , which will need to be re-written a bit since the text explicitly references that pattern.
Now that has merged, can this be closed?
That PR only says it address part of the issue.
fixed all the instances of this pattern that I could find in the docs, except for the guessing game. The guessing game has a paragraph that talks about the thing, and I wasn't sure if we just want to delete that or rewrite it (and how to rewrite it).

Discussion:
let mut guess = String::new(); io::stdin().read_line(&mut guess) <del> .ok() </del> .expect("Failed to read line"); println!("You guessed: {}", guess);

```rust,ignore io::stdin().read_line(&mut guess) <del> .ok() </del> .expect("Failed to read line"); ```

code: ```rust,ignore <del> .ok() </del> .expect("Failed to read line"); ```

done: ```rust,ignore <del> io::stdin().read_line(&mut guess).ok().expect("failed to read line"); </del> <ins> io::stdin().read_line(&mut guess).expect("failed to read line"); </ins> ``` <del> But that gets hard to read. So we’ve split it up, three lines for three method calls. We already talked about `read_line()`, but what about `ok()` and `expect()`? Well, we already mentioned that `read_line()` puts what the user types into the `&mut String` we pass it. But it also returns a value: in this case, an [`io::Result`][ioresult]. Rust has a number of types named `Result` in its standard library: a generic [`Result`][result], and then specific versions for sub-libraries, like `io::Result`. </del> <ins> But that gets hard to read. So we’ve split it up, three lines for three method calls. We already talked about `read_line()`, but what about `expect()`? Well, we already mentioned that `read_line()` puts what the user types into the `&mut String` we pass it. But it also returns a value: in this case, an [`io::Result`][ioresult]. Rust has a number of types named `Result` in its standard library: a generic [`Result`][result], and then specific versions for sub-libraries, like `io::Result`. </ins> [ioresult]: ../std/io/type.Result.html [result]: ../std/result/enum.Result.html The purpose of these `Result` types is to encode error handling information. Values of the `Result` type, like any type, have methods defined on them. In <del> this case, `io::Result` has an `ok()` method, which says ‘we want to assume this value is a successful one. If not, just throw away the error information’. Why throw it away? Well, for a basic program, we just want to print a generic error, as basically any issue means we can’t continue. The [`ok()` method][ok] returns a value which has another method defined on it: `expect()`. The [`expect()` method][expect] takes a value it’s called on, and if it isn’t a successful one, [`panic!`][panic]s with a message you passed it. A `panic!` like this will cause our program to crash, displaying the message. [ok]: ../std/result/enum.Result.html#method.ok </del> <ins> this case, `io::Result` has an [`expect()` method][expect] that takes a value it’s called on, and if it isn’t a successful one, [`panic!`][panic]s with a message you passed it. A `panic!` like this will cause our program to crash, displaying the message. </ins> [expect]: ../std/option/enum.Option.html#method.expect [panic]: error-handling.html

let mut guess = String::new(); io::stdin().read_line(&mut guess) <del> .ok() </del> .expect("failed to read line"); println!("You guessed: {}", guess);

```rust,ignore let guess: u32 = guess.trim().parse() <del> .ok() </del> .expect("Please type a number!"); ```

guess.trim().parse() ``` <del> Followed by an `ok().expect()` invocation. Here, `guess` refers to the old `guess`, the one that was a `String` with our input in it. The `trim()` method on `String`s will eliminate any white space at the beginning and end of our string. This is important, as we had to press the ‘return’ key to satisfy `read_line()`. This means that if we type `5` and hit return, `guess` looks like this: `5n`. The `n` represents ‘newline’, the enter key. `trim()` gets rid of this, leaving our string with just the `5`. The [`parse()` method on strings][parse] parses a string into some kind of number. Since it can parse a variety of numbers, we need to give Rust a hint as to the exact type of number we want. Hence, `let guess: u32`. The colon (`:`) after `guess` tells Rust we’re going to annotate its type. `u32` is an unsigned, thirty-two bit integer. Rust has [a number of built-in number types][number], but we’ve chosen `u32`. It’s a good default choice for a small positive number. </del> <ins> Here, `guess` refers to the old `guess`, the one that was a `String` with our input in it. The `trim()` method on `String`s will eliminate any white space at the beginning and end of our string. This is important, as we had to press the ‘return’ key to satisfy `read_line()`. This means that if we type `5` and hit return, `guess` looks like this: `5n`. The `n` represents ‘newline’, the enter key. `trim()` gets rid of this, leaving our string with just the `5`. The [`parse()` method on strings][parse] parses a string into some kind of number. Since it can parse a variety of numbers, we need to give Rust a hint as to the exact type of number we want. Hence, `let guess: u32`. The colon (`:`) after `guess` tells Rust we’re going to annotate its type. `u32` is an unsigned, thirty-two bit integer. Rust has [a number of built-in number types][number], but we’ve chosen `u32`. It’s a good default choice for a small positive number. </ins> [parse]: ../std/primitive.str.html#method.parse [number]: primitive-types.html#numeric-types Just like `read_line()`, our call to `parse()` could cause an error. What if our string contained `A👍%`? There’d be no way to convert that to a number. As <del> such, we’ll do the same thing we did with `read_line()`: use the `ok()` and `expect()` methods to crash if there’s an error. </del> <ins> such, we’ll do the same thing we did with `read_line()`: use the `expect()` method to crash if there’s an error. </ins> Let’s try our program out!

let mut guess = String::new(); io::stdin().read_line(&mut guess) <del> .ok() </del> .expect("failed to read line"); let guess: u32 = guess.trim().parse() <del> .ok() </del> .expect("Please type a number!"); println!("You guessed: {}", guess);

``` This is how you generally move from ‘crash on error’ to ‘actually handle the <del> error’, by switching from `ok().expect()` to a `match` statement. The `Result` </del> returned by `parse()` is an `enum` just like `Ordering`, but in this case, each variant has some data associated with it: `Ok` is a success, and `Err` is a failure. Each contains more information: the successfully parsed integer, or an

let mut guess = String::new(); io::stdin().read_line(&mut guess) <del> .ok() </del> .expect("failed to read line"); let guess: u32 = match guess.trim().parse() {