rust-lang/rust-clippy

Lint for Iterator + Copy

Open

#1,534 创建于 2017年2月13日

在 GitHub 查看
 (1 评论) (0 反应) (0 负责人)Rust (10,406 star) (1,391 fork)batch import
A-lintE-mediumL-correctnessgood first issue

描述

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.

贡献者指南

Lint for Iterator + Copy · rust-lang/rust-clippy#1534 | Good First Issue