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/errors6.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'rustlings/exercises/13_error_handling/errors6.rs') diff --git a/rustlings/exercises/13_error_handling/errors6.rs b/rustlings/exercises/13_error_handling/errors6.rs index b1995e0..353b50b 100644 --- a/rustlings/exercises/13_error_handling/errors6.rs +++ b/rustlings/exercises/13_error_handling/errors6.rs @@ -25,7 +25,9 @@ impl ParsePosNonzeroError { } // TODO: Add another error conversion function here. - // fn from_parse_int(???) -> Self { ??? } + fn from_parse_int(err: ParseIntError) -> Self { + Self::ParseInt(err) + } } #[derive(PartialEq, Debug)] @@ -43,7 +45,7 @@ impl PositiveNonzeroInteger { fn parse(s: &str) -> Result { // TODO: change this to return an appropriate error instead of panicking // when `parse()` returns an error. - let x: i64 = s.parse().unwrap(); + let x: i64 = s.parse().map_err(ParsePosNonzeroError::from_parse_int)?; Self::new(x).map_err(ParsePosNonzeroError::from_creation) } } -- cgit v1.2.3