1
0
Fork 0
mirror of https://github.com/notohh/rustlings.git synced 2025-08-12 22:03:36 -04:00

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.
This commit is contained in:
Taylor Yu 2021-06-09 18:13:57 -05:00
commit b7ddd09fab
3 changed files with 35 additions and 23 deletions
exercises/error_handling

View file

@ -43,8 +43,8 @@ impl PositiveNonzeroInteger {
impl fmt::Display for CreationError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let description = match *self {
CreationError::Negative => "Number is negative",
CreationError::Zero => "Number is zero",
CreationError::Negative => "number is negative",
CreationError::Zero => "number is zero",
};
f.write_str(description)
}