]> git.lizzy.rs Git - rust.git/blob - src/docs/match_as_ref.txt
Add iter_kv_map lint
[rust.git] / src / docs / match_as_ref.txt
1 ### What it does
2 Checks for match which is used to add a reference to an
3 `Option` value.
4
5 ### Why is this bad?
6 Using `as_ref()` or `as_mut()` instead is shorter.
7
8 ### Example
9 ```
10 let x: Option<()> = None;
11
12 let r: Option<&()> = match x {
13     None => None,
14     Some(ref v) => Some(v),
15 };
16 ```
17
18 Use instead:
19 ```
20 let x: Option<()> = None;
21
22 let r: Option<&()> = x.as_ref();
23 ```