From b9b008c1d4a730335bdc9d465b0fdf7869fb09d4 Mon Sep 17 00:00:00 2001 From: Hunter Kvalevog Date: Sun, 27 Sep 2026 12:11:32 -0500 Subject: rustlings: complete 13 --- rustlings/exercises/13_error_handling/errors4.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'rustlings/exercises/13_error_handling/errors4.rs') diff --git a/rustlings/exercises/13_error_handling/errors4.rs b/rustlings/exercises/13_error_handling/errors4.rs index 144fce7..e5f3d39 100644 --- a/rustlings/exercises/13_error_handling/errors4.rs +++ b/rustlings/exercises/13_error_handling/errors4.rs @@ -11,6 +11,12 @@ impl PositiveNonzeroInteger { fn new(value: i64) -> Result { // TODO: This function shouldn't always return an `Ok`. // Read the tests below to clarify what should be returned. + if value < 0 { + return Err(CreationError::Negative); + } + if value == 0 { + return Err(CreationError::Zero); + } Ok(Self(value as u64)) } } -- cgit v1.2.3