rust-lang/rust-clippy

Iterators: suggest `position()` instead of `enumerate() + find() + .0`

Open

#2282 aperta il 20 dic 2017

Vedi su GitHub
 (5 commenti) (3 reazioni) (1 assegnatario)Rust (1391 fork)batch import
A-lintT-middlegood first issue

Metriche repository

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

Descrizione

This is sort of the opposite of #456. I recently wrote let idx = v.iter().enumerate().find(|&(_, &ch)| ch == '|').unwrap().0, when I should have written let idx = v.iter().position(|&ch| ch == '|').unwrap(). I'd have to think a little on the exact rule that should be followed here, but it would be nice if clippy could catch this pattern.

Guida contributor