]> git.lizzy.rs Git - rust.git/blob - src/docs/unnecessary_unwrap.txt
[Arithmetic] Consider literals
[rust.git] / src / docs / unnecessary_unwrap.txt
1 ### What it does
2 Checks for calls of `unwrap[_err]()` that cannot fail.
3
4 ### Why is this bad?
5 Using `if let` or `match` is more idiomatic.
6
7 ### Example
8 ```
9 if option.is_some() {
10     do_something_with(option.unwrap())
11 }
12 ```
13
14 Could be written:
15
16 ```
17 if let Some(value) = option {
18     do_something_with(value)
19 }
20 ```