errors6 solution

This commit is contained in:
mo8it
2024-06-27 01:12:50 +02:00
parent 129884aff7
commit b1daea1fe8
3 changed files with 138 additions and 52 deletions
+3 -7
View File
@@ -714,17 +714,13 @@ https://doc.rust-lang.org/stable/rust-by-example/error/multiple_error_types/reen
name = "errors6"
dir = "13_error_handling"
hint = """
This exercise uses a completed version of `PositiveNonzeroInteger` from
errors4.
This exercise uses a completed version of `PositiveNonzeroInteger` from the
previous exercises.
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!
You can create another function inside `impl ParsePosNonzeroError` to use
with `map_err()`.
can then use the `?` operator to return early.
Read more about `map_err()` in the `std::result` documentation:
https://doc.rust-lang.org/std/result/enum.Result.html#method.map_err"""