diff options
Diffstat (limited to '')
-rw-r--r-- | src/tools/clippy/src/docs/explicit_deref_methods.txt | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/tools/clippy/src/docs/explicit_deref_methods.txt b/src/tools/clippy/src/docs/explicit_deref_methods.txt new file mode 100644 index 000000000..e14e981c7 --- /dev/null +++ b/src/tools/clippy/src/docs/explicit_deref_methods.txt @@ -0,0 +1,24 @@ +### What it does +Checks for explicit `deref()` or `deref_mut()` method calls. + +### Why is this bad? +Dereferencing by `&*x` or `&mut *x` is clearer and more concise, +when not part of a method chain. + +### Example +``` +use std::ops::Deref; +let a: &mut String = &mut String::from("foo"); +let b: &str = a.deref(); +``` + +Use instead: +``` +let a: &mut String = &mut String::from("foo"); +let b = &*a; +``` + +This lint excludes: +``` +let _ = d.unwrap().deref(); +```
\ No newline at end of file |