diff options
Diffstat (limited to 'src/tools/clippy/src/docs/explicit_iter_loop.txt')
-rw-r--r-- | src/tools/clippy/src/docs/explicit_iter_loop.txt | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/tools/clippy/src/docs/explicit_iter_loop.txt b/src/tools/clippy/src/docs/explicit_iter_loop.txt new file mode 100644 index 000000000..cabe72e91 --- /dev/null +++ b/src/tools/clippy/src/docs/explicit_iter_loop.txt @@ -0,0 +1,25 @@ +### What it does +Checks for loops on `x.iter()` where `&x` will do, and +suggests the latter. + +### Why is this bad? +Readability. + +### Known problems +False negatives. We currently only warn on some known +types. + +### Example +``` +// with `y` a `Vec` or slice: +for x in y.iter() { + // .. +} +``` + +Use instead: +``` +for x in &y { + // .. +} +```
\ No newline at end of file |