rust-lang/rust-clippy

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

Open

#2,282 建立於 2017年12月20日

在 GitHub 查看
 (5 留言) (3 反應) (1 負責人)Rust (1,391 fork)batch import
A-lintT-middlegood first issue

倉庫指標

Star
 (10,406 star)
PR 合併指標
 (平均合併 19天 22小時) (30 天內合併 113 個 PR)

描述

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.

貢獻者指南