diff --git a/exercises/error_handling/errors2.rs b/exercises/error_handling/errors2.rs index 1cd8fc66..8720981d 100644 --- a/exercises/error_handling/errors2.rs +++ b/exercises/error_handling/errors2.rs @@ -17,16 +17,20 @@ // one is a lot shorter! // Execute `rustlings hint errors2` or use the `hint` watch subcommand for a hint. -// I AM NOT DONE + use std::num::ParseIntError; pub fn total_cost(item_quantity: &str) -> Result { let processing_fee = 1; let cost_per_item = 5; - let qty = item_quantity.parse::(); - Ok(qty * cost_per_item + processing_fee) + match item_quantity.parse::(){ + Ok(qty) => Ok(qty * cost_per_item + processing_fee), + Err(err)=> Err(err), + } + + } #[cfg(test)]