diff options
| author | y21 <30553356+y21@users.noreply.github.com> | 2023-10-26 01:07:20 +0200 |
|---|---|---|
| committer | y21 <30553356+y21@users.noreply.github.com> | 2023-10-26 01:07:20 +0200 |
| commit | 45f94c7598b5720c1f2d3fdd7485e53e6a651930 (patch) | |
| tree | 8b4f279c79aa9b1541d05cb38662ddd8b9f1f96d | |
| parent | 3c501e4e4110ca107e739275c348e395dbfff8ea (diff) | |
| download | rust-45f94c7598b5720c1f2d3fdd7485e53e6a651930.tar.gz rust-45f94c7598b5720c1f2d3fdd7485e53e6a651930.zip | |
mention restriction to exported types as a limitation
| -rw-r--r-- | clippy_lints/src/iter_without_into_iter.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/clippy_lints/src/iter_without_into_iter.rs b/clippy_lints/src/iter_without_into_iter.rs index 1add49a2542..e3cb29da5e1 100644 --- a/clippy_lints/src/iter_without_into_iter.rs +++ b/clippy_lints/src/iter_without_into_iter.rs @@ -19,6 +19,11 @@ declare_clippy_lint! { /// It's not bad, but having them is idiomatic and allows the type to be used in for loops directly /// (`for val in &iter {}`), without having to first call `iter()` or `iter_mut()`. /// + /// ### Limitations + /// This lint is restricted to exported types only, because it is aimed at guiding towards an + /// idiomatic, _public_ API. + /// Implementing the `IntoIterator` trait when it is not needed or used anywhere doesn't help or improve the code. + /// /// ### Example /// ```rust /// struct MySlice<'a>(&'a [u8]); @@ -61,6 +66,12 @@ declare_clippy_lint! { /// by just calling `.iter()`, instead of the more awkward `<&Type>::into_iter` or `(&val).into_iter()` syntax /// in case of ambiguity with another `IntoIterator` impl. /// + /// ### Limitations + /// This lint is restricted to exported types only, because it is aimed at guiding towards an + /// idiomatic, _public_ API. + /// Adding an `iter` or `iter_mut` for private types when it is not needed or used doesn't improve code, + /// and in fact, is linted against by the `dead_code` lint. + /// /// ### Example /// ```rust /// struct MySlice<'a>(&'a [u8]); |
