diff options
| author | Taylor Yu <tlyu@mit.edu> | 2021-06-09 18:13:57 -0500 |
|---|---|---|
| committer | Taylor Yu <tlyu@mit.edu> | 2021-06-09 23:27:53 -0500 |
| commit | b7ddd09fab97fc96f032bc8c0b9e1a64e5ffbcdd (patch) | |
| tree | 4f3109041b10c432405984c0f04a0c4a7fa092b3 /info.toml | |
| parent | 68d3ac567cd5c23f5593c2f4df51612bca3d09a9 (diff) | |
address review feedback
Adjust error text and naming to conform with best practices.
Use `map_err()` instead of `or()`. Wrap lower-level errors instead of
ignoring their details.
Also, don't "cheat" by bypassing the `new()` function in tests.
Fix a dangling reference in the try_from_into hints.
Diffstat (limited to 'info.toml')
| -rw-r--r-- | info.toml | 21 |
1 files changed, 12 insertions, 9 deletions
@@ -532,16 +532,19 @@ path = "exercises/error_handling/errors6.rs" mode = "test" hint = """ This exercise uses a completed version of `PositiveNonzeroInteger` from -the errors4. +errors4. -Below the TODO line, there is an example of using the `.or()` method -on a `Result` to transform one type of error into another. Try using -something similar on the `Result` from `parse()`. You might use the `?` -operator to return early from the function, or you might use a `match` -expression, or maybe there's another way! +Below the line that TODO asks you to change, there is an example of using +the `map_err()` method on a `Result` to transform one type of error into +another. Try using something similar on the `Result` from `parse()`. You +might use the `?` operator to return early from the function, or you might +use a `match` expression, or maybe there's another way! -Read more about `.or()` in the `std::result` documentation: -https://doc.rust-lang.org/std/result/enum.Result.html#method.or""" +You can create another function inside `impl ParsePosNonzeroError` to use +with `map_err()`. + +Read more about `map_err()` in the `std::result` documentation: +https://doc.rust-lang.org/std/result/enum.Result.html#method.map_err""" # Generics @@ -927,7 +930,7 @@ hint = """ Follow the steps provided right before the `TryFrom` implementation. You can also use the example at https://doc.rust-lang.org/std/convert/trait.TryFrom.html -You might want to look back at the exercise errorsn (or its hints) to remind +You might want to look back at the exercise errors5 (or its hints) to remind yourself about how `Box<dyn Error>` works. If you're trying to return a string as an error, note that neither `str` |
