From 5e1ca4b99577578a1c92d71eeba49d88f60dcedc Mon Sep 17 00:00:00 2001 From: Noah Cairns Date: Wed, 15 Jun 2022 09:40:30 -0400 Subject: fix(errors5): improve exercise instructions --- info.toml | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'info.toml') diff --git a/info.toml b/info.toml index b13ed45..97c174f 100644 --- a/info.toml +++ b/info.toml @@ -619,22 +619,17 @@ name = "errors5" path = "exercises/error_handling/errors5.rs" mode = "compile" hint = """ -There are two different possible `Result` types produced within -`main()`, which are propagated using `?` operators. How do we declare a -return type from `main()` that allows both? - -Another hint: under the hood, the `?` operator calls `From::from` -on the error value to convert it to a boxed trait object, a -`Box`, which is polymorphic-- that means that lots of -different kinds of errors can be returned from the same function because -all errors act the same since they all implement the `error::Error` trait. +There are two different possible `Result` types produced within `main()`, which are +propagated using `?` operators. How do we declare a return type from `main()` that allows both? + +Under the hood, the `?` operator calls `From::from` on the error value to convert it to a boxed +trait object, a `Box`. This boxed trait object is polymorphic, and since all +errors implement the `error:Error` trait, we can capture lots of different errors in one "Box" +object. + Check out this section of the book: https://doc.rust-lang.org/book/ch09-02-recoverable-errors-with-result.html#a-shortcut-for-propagating-errors-the--operator -This exercise uses some concepts that we won't get to until later in the -course, like `Box` and the `From` trait. It's not important to understand -them in detail right now, but you can read ahead if you like. - Read more about boxing errors: https://doc.rust-lang.org/stable/rust-by-example/error/multiple_error_types/boxing_errors.html -- cgit v1.2.3