rust-lang/rust-clippy

Lint for Iterator + Copy

Open

#1534 aperta il 13 feb 2017

Vedi su GitHub
 (1 commento) (0 reazioni) (0 assegnatari)Rust (1391 fork)batch import
A-lintE-mediumL-correctnessgood first issue

Metriche repository

Star
 (10.406 star)
Metriche merge PR
 (Merge medio 19g 22h) (113 PR mergiate in 30 g)

Descrizione

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.

Guida contributor