from_str solution

This commit is contained in:
mo8it
2024-07-02 01:03:55 +02:00
parent cddaf4881e
commit e3c8c457ba
3 changed files with 163 additions and 36 deletions
+4 -6
View File
@@ -1183,13 +1183,11 @@ hint = """
The implementation of `FromStr` should return an `Ok` with a `Person` object,
or an `Err` with an error if the string is not valid.
This is almost like the `from_into` exercise, but returning errors instead
of falling back to a default value.
This is almost like the previous `from_into` exercise, but returning errors
instead of falling back to a default value.
Look at the test cases to see which error variants to return.
Another hint: You can use the `map_err` method of `Result` with a function
or a closure to wrap the error from `parse::<usize>`.
Another hint: You can use the `map_err` method of `Result` with a function or a
closure to wrap the error from `parse::<u8>`.
Yet another hint: If you would like to propagate errors by using the `?`
operator in your solution, you might want to look at