rust-lang/rust-clippy

Lint for Iterator + Copy

Open

#1 534 ouverte le 13 févr. 2017

Voir sur GitHub
 (1 commentaire) (0 réactions) (0 assignés)Rust (1 391 forks)batch import
A-lintE-mediumL-correctnessgood first issue

Métriques du dépôt

Stars
 (10 406 stars)
Métriques de merge PR
 (Merge moyen 19j 22h) (113 PRs mergées en 30 j)

Description

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.

Guide contributeur