rollup merge of #19312: steveklabnik/gh19177
This commit is contained in:
commit
935a39b3cd
1 changed files with 14 additions and 1 deletions
|
@ -4013,6 +4013,19 @@ match origin {
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
If you want to match against a slice or array, you can use `[]`:
|
||||||
|
|
||||||
|
```{rust}
|
||||||
|
fn main() {
|
||||||
|
let v = vec!["match_this", "1"];
|
||||||
|
|
||||||
|
match v.as_slice() {
|
||||||
|
["match_this", second] => println!("The second element is {}", second),
|
||||||
|
_ => {},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
Whew! That's a lot of different ways to match things, and they can all be
|
Whew! That's a lot of different ways to match things, and they can all be
|
||||||
mixed and matched, depending on what you're doing:
|
mixed and matched, depending on what you're doing:
|
||||||
|
|
||||||
|
@ -5271,7 +5284,7 @@ immediately.
|
||||||
|
|
||||||
## Success and failure
|
## Success and failure
|
||||||
|
|
||||||
Tasks don't always succeed, they can also panic. A task that wishes to panic
|
Tasks don't always succeed, they can also panic. A task that wishes to panic
|
||||||
can call the `panic!` macro, passing a message:
|
can call the `panic!` macro, passing a message:
|
||||||
|
|
||||||
```{rust}
|
```{rust}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue