summaryrefslogtreecommitdiff
path: root/exercises
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2019-05-23 11:01:15 +0000
committerbors <bors@rust-lang.org>2019-05-23 11:01:15 +0000
commit8bf8cbbd61a909b0580162c9f1fd314885daf1c2 (patch)
tree85eb444f07cf721144fb674bbc3d2c173ee4084c /exercises
parentfffbb60ed92bbe83b9706a07080216f0549265c0 (diff)
parentf50784410243054e3f04f92f9ead7cd623866000 (diff)
Auto merge of #162 - c-rustacean:rustfmt-and-ws-fixes, r=komaeda
errorsn.rs: Separate also the hints from each other to avoid accidental viewing
Diffstat (limited to 'exercises')
-rw-r--r--exercises/error_handling/errorsn.rs76
1 files changed, 76 insertions, 0 deletions
diff --git a/exercises/error_handling/errorsn.rs b/exercises/error_handling/errorsn.rs
index 8d39967..b670729 100644
--- a/exercises/error_handling/errorsn.rs
+++ b/exercises/error_handling/errorsn.rs
@@ -146,11 +146,49 @@ impl error::Error for CreationError {
// `read_and_validate` returns and`test_with_str` has its signature fully
// specified.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// Next hint: There are three places in `read_and_validate` that we call a
// function that returns a `Result` (that is, the functions might fail).
// Apply the `?` operator on those calls so that we return immediately from
// `read_and_validate` if those function calls fail.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// Another hint: under the hood, the `?` operator calls `From::from`
// on the error value to convert it to a boxed trait object, a Box<error::Error>,
// which is polymorphic-- that means that lots of different kinds of errors
@@ -159,12 +197,50 @@ impl error::Error for CreationError {
// Check out this section of the book:
// https://doc.rust-lang.org/stable/book/second-edition/ch09-02-recoverable-errors-with-result.html#a-shortcut-for-propagating-errors-the--operator
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// Another another hint: Note that because the `?` operator returns
// the *unwrapped* value in the `Ok` case, if we want to return a `Result` from
// `read_and_validate` for *its* success case, we'll have to rewrap a value
// that we got from the return value of a `?`ed call in an `Ok`-- this will
// look like `Ok(something)`.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// Another another another hint: `Result`s must be "used", that is, you'll
// get a warning if you don't handle a `Result` that you get in your
// function. Read more about that in the `std::result` module docs: