EN | DE

Stage 3.7: match

Miss your switch statement? Rust has an incredibly useful keyword for matching all possible conditions of a value and executing a code path if the match is true. Let's see how this works for numbers. We will have more to say in future chapters on pattern matching more complex data. I promise you it will be worth the wait.

match is exhaustive, so all cases must be handled.

Matching combined with destructuring is by far one of the most common patterns you will see in all of Rust.

Further information: