From dcfb427b09585f0193f0a294443fdf99f11c64cb Mon Sep 17 00:00:00 2001 From: marisa Date: Mon, 11 Nov 2019 13:37:43 +0100 Subject: [PATCH] fix(errors3): Update hint Closes #185. --- exercises/error_handling/errors3.rs | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/exercises/error_handling/errors3.rs b/exercises/error_handling/errors3.rs index 9c29af58..31800fce 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 { -// 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`?