Skip to content

Commit ec0a00e

Browse files
committed
Use find_map instead of find() + map()
1 parent 8642fc9 commit ec0a00e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

clippy_lints/src/multiple_crate_versions.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ declare_clippy_lint! {
3737
declare_lint_pass!(MultipleCrateVersions => [MULTIPLE_CRATE_VERSIONS]);
3838

3939
impl LateLintPass<'_, '_> for MultipleCrateVersions {
40-
#[allow(clippy::find_map)]
4140
fn check_crate(&mut self, cx: &LateContext<'_, '_>, _: &Crate<'_>) {
4241
if !run_lints(cx, &[MULTIPLE_CRATE_VERSIONS], CRATE_HIR_ID) {
4342
return;
@@ -56,7 +55,9 @@ impl LateLintPass<'_, '_> for MultipleCrateVersions {
5655

5756
if_chain! {
5857
if let Some(resolve) = &metadata.resolve;
59-
if let Some(local_id) = packages.iter().find(|p| p.name == *local_name).map(|p| &p.id);
58+
if let Some(local_id) = packages
59+
.iter()
60+
.find_map(|p| if p.name == *local_name { Some(&p.id) } else { None });
6061
then {
6162
for (name, group) in &packages.iter().group_by(|p| p.name.clone()) {
6263
let group: Vec<&Package> = group.collect();

0 commit comments

Comments
 (0)