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:
parent
68d3ac567c
commit
b7ddd09fab
3 changed files with 35 additions and 23 deletions
exercises/error_handling
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue