This commit is contained in:
Tirth Patel 2024-04-11 15:43:28 -02:30
parent 294a568e3f
commit 865ae38c69

View File

@ -19,14 +19,13 @@
// Execute `rustlings hint errors2` or use the `hint` watch subcommand for a // Execute `rustlings hint errors2` or use the `hint` watch subcommand for a
// hint. // hint.
// I AM NOT DONE
use std::num::ParseIntError; use std::num::ParseIntError;
pub fn total_cost(item_quantity: &str) -> Result<i32, ParseIntError> { pub fn total_cost(item_quantity: &str) -> Result<i32, ParseIntError> {
let processing_fee = 1; let processing_fee = 1;
let cost_per_item = 5; let cost_per_item = 5;
let qty = item_quantity.parse::<i32>(); let qty = item_quantity.parse::<i32>()?;
Ok(qty * cost_per_item + processing_fee) Ok(qty * cost_per_item + processing_fee)
} }