diff --git a/src/error-handling/try-operator.md b/src/error-handling/try-operator.md index c9a28e8e..4b3a0523 100644 --- a/src/error-handling/try-operator.md +++ b/src/error-handling/try-operator.md @@ -49,5 +49,12 @@ Key points: * The `username` variable can be either `Ok(string)` or `Err(error)`. * Use the `fs::write` call to test out the different scenarios: no file, empty file, file with username. +* The return type of the function has to be compatible with the nested functions it calls. For instance, +a function returning a `Result` can only apply the `?` operator on a function returning a +`Result`. It cannot apply the `?` operator on a function returning a `Result` +or an `Option`. Reciprocally, a function returning an `Option` can only apply the `?` operator +on a function returning an `Option`. + * You can convert incompatible types into one another with the different `Option` and `Result` methods + such as `Option::ok_or`, `Result::ok`, `Result::err`.