]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/src/docs/explicit_deref_methods.txt
Rollup merge of #101772 - est31:replace_placeholder_diagnostics, r=jackh726
[rust.git] / src / tools / clippy / src / docs / explicit_deref_methods.txt
1 ### What it does
2 Checks for explicit `deref()` or `deref_mut()` method calls.
3
4 ### Why is this bad?
5 Dereferencing by `&*x` or `&mut *x` is clearer and more concise,
6 when not part of a method chain.
7
8 ### Example
9 ```
10 use std::ops::Deref;
11 let a: &mut String = &mut String::from("foo");
12 let b: &str = a.deref();
13 ```
14
15 Use instead:
16 ```
17 let a: &mut String = &mut String::from("foo");
18 let b = &*a;
19 ```
20
21 This lint excludes:
22 ```
23 let _ = d.unwrap().deref();
24 ```