rust-lang/rust-clippy

Lint for Iterator + Copy

Open

#1.534 geöffnet am 13. Feb. 2017

Auf GitHub ansehen
 (1 Kommentar) (0 Reaktionen) (0 zugewiesene Personen)Rust (1.391 Forks)batch import
A-lintE-mediumL-correctnessgood first issue

Repository-Metriken

Stars
 (10.406 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 19T 22h) (113 gemergte PRs in 30 T)

Beschreibung

Implementing Copy for iterators makes footguns, and the standard library settled not to do so for now.

let mut it = /* a Copy + Iterator */;
for x in it { if cond { break; } } // `it` copied here (forgot to `&mut it`)
let x = it.next(); // `it` is in the initial state

Clippy should have a lint that warns if "use of the original iterator after copied" is detected.

Contributor Guide