Exercise: Pattern Matching with If Let
Let's go through what you’ve learned in this chapter.
We'll cover the following
This exercise is all about using if let
to see if an error occurred.
Problem statement
You need a safe way to check if a string contains a valid integer. To get started, we’ve included a function that performs the conversion.
Use if let
to check if the strings “12” and “twelve” are valid Rust
integers.
Coding challenge
Add tests for the application below. We encourage you to try solving it yourself before looking at the solution.
Get hands-on with 1400+ tech skills courses.