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