]> git.lizzy.rs Git - rust.git/blob - src/docs/ref_binding_to_reference.txt
[Arithmetic] Consider literals
[rust.git] / src / docs / ref_binding_to_reference.txt
1 ### What it does
2 Checks for `ref` bindings which create a reference to a reference.
3
4 ### Why is this bad?
5 The address-of operator at the use site is clearer about the need for a reference.
6
7 ### Example
8 ```
9 let x = Some("");
10 if let Some(ref x) = x {
11     // use `x` here
12 }
13 ```
14
15 Use instead:
16 ```
17 let x = Some("");
18 if let Some(x) = x {
19     // use `&x` here
20 }
21 ```