rust-lang/rust-clippy

Lint for Iterator + Copy

Open

#1.534 aberto em 13 de fev. de 2017

Ver no GitHub
 (1 comment) (0 reactions) (0 assignees)Rust (1.391 forks)batch import
A-lintE-mediumL-correctnessgood first issue

Métricas do repositório

Stars
 (10.406 stars)
Métricas de merge de PR
 (Mesclagem média 19d 22h) (113 fundiu PRs em 30d)

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.

Guia do colaborador