Skip to content

Commit

Permalink
Add hints on Result-Option conversion (fix: rust-lang#2173)
Browse files Browse the repository at this point in the history
Signed-off-by: Eddy Petrișor <[email protected]>
  • Loading branch information
eddyp committed Nov 25, 2019
1 parent 81ebaa2 commit b02adc0
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/ch09-02-recoverable-errors-with-result.md
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,10 @@ E>` if you have no restrictions preventing that. The other technique is to use
a `match` or one of the `Result<T, E>` methods to handle the `Result<T, E>` in
whatever way is appropriate.

Note that changing from `Result<T,E>` to `Option<T> or the other way around,
is possible with the methods `ok()`, `err()` and, respectively, `Option<T>`'s
`ok\_or()` or `ok\_or\_else()`.

The `main` function is special, and there are restrictions on what its return
type must be. One valid return type for main is `()`, and conveniently, another
valid return type is `Result<T, E>`, as shown here:
Expand Down

0 comments on commit b02adc0

Please sign in to comment.