]> git.lizzy.rs Git - rust.git/blob - src/docs/manual_unwrap_or.txt
Auto merge of #9425 - kraktus:patch-1, r=xFrednet
[rust.git] / src / docs / manual_unwrap_or.txt
1 ### What it does
2 Finds patterns that reimplement `Option::unwrap_or` or `Result::unwrap_or`.
3
4 ### Why is this bad?
5 Concise code helps focusing on behavior instead of boilerplate.
6
7 ### Example
8 ```
9 let foo: Option<i32> = None;
10 match foo {
11     Some(v) => v,
12     None => 1,
13 };
14 ```
15
16 Use instead:
17 ```
18 let foo: Option<i32> = None;
19 foo.unwrap_or(1);
20 ```