Examples
Matching Literals
Matching Named Variables
Multiple Patterns
Matching Ranges of Values with ..=
Destructuring
Destructuring to break apart Values
-
Destructuring Structs
-
Shorthand version
Destructuring and matching literal values in one pattern
Destructuring Enums
Enums can also be deconstructed:
Destructuring nested Structs and Enums
Nested structs and
enums can also be destructured:
Destructuring Structs and Tuples
Ignoring Values in a Pattern
_
-
Ignoring an entire Value with _
-
Ignoring parts of a Value with a nested _
-
Ignoring an unused Variable by starting its name with _
…
-
Ignoring remaining parts of a Value with …
@ Bindings