Exercise 3 · Chapter: Error HandlingRequired+50 XP
Parse a Number
Use match to parse the string "42" into an i32. Print the result if it succeeds, or an error message if it fails.
Expected output:
Parsed: 42
Hints:
- Use
"42".parse::<i32>() - Match on
Ok(n)andErr(e)
rust
fn main() {
}
Output
Run your code to see the output here.