rust-lang/rust-clippy

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

Open

#2.282 aberto em 20 de dez. de 2017

Ver no GitHub
 (5 comments) (3 reactions) (1 assignee)Rust (1.391 forks)batch import
A-lintT-middlegood 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

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.

Guia do colaborador