Skip to content

Commit 45f94c7

Browse files
committed
mention restriction to exported types as a limitation
1 parent 3c501e4 commit 45f94c7

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

clippy_lints/src/iter_without_into_iter.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ declare_clippy_lint! {
1919
/// It's not bad, but having them is idiomatic and allows the type to be used in for loops directly
2020
/// (`for val in &iter {}`), without having to first call `iter()` or `iter_mut()`.
2121
///
22+
/// ### Limitations
23+
/// This lint is restricted to exported types only, because it is aimed at guiding towards an
24+
/// idiomatic, _public_ API.
25+
/// Implementing the `IntoIterator` trait when it is not needed or used anywhere doesn't help or improve the code.
26+
///
2227
/// ### Example
2328
/// ```rust
2429
/// struct MySlice<'a>(&'a [u8]);
@@ -61,6 +66,12 @@ declare_clippy_lint! {
6166
/// by just calling `.iter()`, instead of the more awkward `<&Type>::into_iter` or `(&val).into_iter()` syntax
6267
/// in case of ambiguity with another `IntoIterator` impl.
6368
///
69+
/// ### Limitations
70+
/// This lint is restricted to exported types only, because it is aimed at guiding towards an
71+
/// idiomatic, _public_ API.
72+
/// Adding an `iter` or `iter_mut` for private types when it is not needed or used doesn't improve code,
73+
/// and in fact, is linted against by the `dead_code` lint.
74+
///
6475
/// ### Example
6576
/// ```rust
6677
/// struct MySlice<'a>(&'a [u8]);

0 commit comments

Comments
 (0)