Complete these tasks to reinforce what you learned in this module.
In main, parse the string "42" into i32 using .parse(). Use match on the Result: print the number on Ok, or print "Parse failed" on Err.
.parse() method on &str returns a Result. Use match to handle Ok and Err; the theory shows the ? operator and Result handling.// Task 1: Parse and match Result. See tasks/TASKS.md.
fn main() {
todo!("Parse \"42\", match and print number");
}
Write a function add_strings(a: &str, b: &str) -> Result<i32, std::num::ParseIntError> that parses both strings to i32 and returns their sum. Use ? for propagation. In main, call it with "10" and "32" and print the result (e.g. with match or unwrap for this task).
i32; if both succeed, return their sum in an Ok. Using ? after each parse will propagate errors. Your function must return Result<..., ParseIntError>.// Task 2: add_strings with ?. See tasks/TASKS.md.
fn main() {
todo!("Implement add_strings and call with \"10\" and \"32\"");
}