diff options
| author | marisa <mokou@posteo.de> | 2019-11-11 13:37:43 +0100 |
|---|---|---|
| committer | marisa <mokou@posteo.de> | 2019-11-11 13:37:43 +0100 |
| commit | dcfb427b09585f0193f0a294443fdf99f11c64cb (patch) | |
| tree | 561ac8ab56db97338451568527a58019822fdbce | |
| parent | ad03d180c9311c0093e56a3531eec1a9a70cdb45 (diff) | |
fix(errors3): Update hint
Closes #185.
| -rw-r--r-- | exercises/error_handling/errors3.rs | 21 |
1 files changed, 3 insertions, 18 deletions
diff --git a/exercises/error_handling/errors3.rs b/exercises/error_handling/errors3.rs index 9c29af5..31800fc 100644 --- a/exercises/error_handling/errors3.rs +++ b/exercises/error_handling/errors3.rs @@ -1,8 +1,7 @@ // errors3.rs // This is a program that is trying to use a completed version of the -// `total_cost` function from the previous exercise. It's not working though-- -// we can't use the `?` operator in the `main()` function! Why not? -// What should we do instead? Scroll for hints! +// `total_cost` function from the previous exercise. It's not working though! +// Why not? What should we do to fix it? Scroll for hints! use std::num::ParseIntError; @@ -45,18 +44,4 @@ pub fn total_cost(item_quantity: &str) -> Result<i32, ParseIntError> { -// Since the `?` operator returns an `Err` early if the thing it's trying to -// do fails, you can only use the `?` operator in functions that have a -// `Result` as their return type. - -// Hence the error that you get if you run this code is: - -// ``` -// error[E0277]: the `?` operator can only be used in a function that returns `Result` (or another type that implements `std::ops::Try`) -// ``` - -// So we have to use another way of handling a `Result` within `main`. - -// Decide what we should do if `pretend_user_input` has a string value that does -// not parse to an integer, and implement that instead of using the `?` -// operator. +// If other functions can return a `Result`, why shouldn't `main`? |
