wip
This commit is contained in:
@@ -3,8 +3,6 @@
|
||||
// Execute `rustlings hint errors4` or use the `hint` watch subcommand for a
|
||||
// hint.
|
||||
|
||||
// I AM NOT DONE
|
||||
|
||||
#[derive(PartialEq, Debug)]
|
||||
struct PositiveNonzeroInteger(u64);
|
||||
|
||||
@@ -17,6 +15,11 @@ enum CreationError {
|
||||
impl PositiveNonzeroInteger {
|
||||
fn new(value: i64) -> Result<PositiveNonzeroInteger, CreationError> {
|
||||
// Hmm... Why is this always returning an Ok value?
|
||||
if value < 0 {
|
||||
return Err(CreationError::Negative);
|
||||
} else if value == 0 {
|
||||
return Err(CreationError::Zero);
|
||||
}
|
||||
Ok(PositiveNonzeroInteger(value as u64))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user