]> git.lizzy.rs Git - rust.git/blob - src/docs/expect_fun_call.txt
Add iter_kv_map lint
[rust.git] / src / docs / expect_fun_call.txt
1 ### What it does
2 Checks for calls to `.expect(&format!(...))`, `.expect(foo(..))`,
3 etc., and suggests to use `unwrap_or_else` instead
4
5 ### Why is this bad?
6 The function will always be called.
7
8 ### Known problems
9 If the function has side-effects, not calling it will
10 change the semantics of the program, but you shouldn't rely on that anyway.
11
12 ### Example
13 ```
14 foo.expect(&format!("Err {}: {}", err_code, err_msg));
15
16 // or
17
18 foo.expect(format!("Err {}: {}", err_code, err_msg).as_str());
19 ```
20
21 Use instead:
22 ```
23 foo.unwrap_or_else(|| panic!("Err {}: {}", err_code, err_msg));
24 ```