We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 48ca6d1 commit 8369a60Copy full SHA for 8369a60
src/doc/guide.md
@@ -3991,6 +3991,19 @@ match origin {
3991
}
3992
```
3993
3994
+If you want to match against a slice or array, you can use `[]`:
3995
+
3996
+```{rust}
3997
+fn main() {
3998
+ let v = vec!["match_this", "1"];
3999
4000
+ match v.as_slice() {
4001
+ ["match_this", second] => println!("The second element is {}", second),
4002
+ _ => {},
4003
+ }
4004
+}
4005
+```
4006
4007
Whew! That's a lot of different ways to match things, and they can all be
4008
mixed and matched, depending on what you're doing:
4009
0 commit comments