File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -4013,6 +4013,19 @@ match origin {
4013
4013
}
4014
4014
```
4015
4015
4016
+ If you want to match against a slice or array, you can use ` [] ` :
4017
+
4018
+ ``` {rust}
4019
+ fn main() {
4020
+ let v = vec!["match_this", "1"];
4021
+
4022
+ match v.as_slice() {
4023
+ ["match_this", second] => println!("The second element is {}", second),
4024
+ _ => {},
4025
+ }
4026
+ }
4027
+ ```
4028
+
4016
4029
Whew! That's a lot of different ways to match things, and they can all be
4017
4030
mixed and matched, depending on what you're doing:
4018
4031
@@ -5271,7 +5284,7 @@ immediately.
5271
5284
5272
5285
## Success and failure
5273
5286
5274
- Tasks don't always succeed, they can also panic. A task that wishes to panic
5287
+ Tasks don't always succeed, they can also panic. A task that wishes to panic
5275
5288
can call the ` panic! ` macro, passing a message:
5276
5289
5277
5290
``` {rust}
You can’t perform that action at this time.
0 commit comments