]> git.lizzy.rs Git - rust.git/blob - src/docs/expect_used.txt
Auto merge of #9421 - xphoniex:fix-#9420, r=giraffate
[rust.git] / src / docs / expect_used.txt
1 ### What it does
2 Checks for `.expect()` or `.expect_err()` calls on `Result`s and `.expect()` call on `Option`s.
3
4 ### Why is this bad?
5 Usually it is better to handle the `None` or `Err` case.
6 Still, for a lot of quick-and-dirty code, `expect` is a good choice, which is why
7 this lint is `Allow` by default.
8
9 `result.expect()` will let the thread panic on `Err`
10 values. Normally, you want to implement more sophisticated error handling,
11 and propagate errors upwards with `?` operator.
12
13 ### Examples
14 ```
15 option.expect("one");
16 result.expect("one");
17 ```
18
19 Use instead:
20 ```
21 option?;
22
23 // or
24
25 result?;
26 ```