From 302d222e25962c323a46a661484594ac8990627f Mon Sep 17 00:00:00 2001 From: Surya Date: Fri, 9 Jul 2021 15:01:58 +0530 Subject: [PATCH] boxed traits --- exercises/error_handling/errors5.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/exercises/error_handling/errors5.rs b/exercises/error_handling/errors5.rs index 365a8691..f8dfe718 100644 --- a/exercises/error_handling/errors5.rs +++ b/exercises/error_handling/errors5.rs @@ -10,6 +10,7 @@ use std::error; use std::fmt; use std::num::ParseIntError; +type Result = std::result::Result>; // TODO: update the return type of `main()` to make this compile. fn main() -> Result<(), ParseIntError> { let pretend_user_input = "42"; @@ -18,6 +19,17 @@ fn main() -> Result<(), ParseIntError> { Ok(()) } +// impl From for ParseIntError{ +// fn from(e: CreationError) -> ParseIntError{ +// return ParseIntError::CreationError(e); +// } +// } + +// impl From for CreationError{ +// fn from(e: ParseIntError) -> CreationError{ +// return CreationError::ParseIntError(e); +// } +// } // Don't change anything below this line. #[derive(PartialEq, Debug)] @@ -34,7 +46,7 @@ impl PositiveNonzeroInteger { match value { x if x < 0 => Err(CreationError::Negative), x if x == 0 => Err(CreationError::Zero), - x => Ok(PositiveNonzeroInteger(x as u64)) + x => Ok(PositiveNonzeroInteger(x as u64)), } } }