mirror of
https://git.aramjonghu.dev/AramJonghu/rustlings.git
synced 2026-09-03 08:43:30 +02:00
errors6 solution
This commit is contained in:
@@ -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"""
|
||||
|
||||
Reference in New Issue
Block a user