From ba3c219b7f22d9b87eee7efdc625aa28837f9e3c Mon Sep 17 00:00:00 2001 From: Alpha Chen Date: Mon, 3 Dec 2018 20:47:45 -0800 Subject: [PATCH] [2018][rust][3.1] cargo clippy --- 2018/rust/src/bin/day_03.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/2018/rust/src/bin/day_03.rs b/2018/rust/src/bin/day_03.rs index b6fbd01..16c01f7 100644 --- a/2018/rust/src/bin/day_03.rs +++ b/2018/rust/src/bin/day_03.rs @@ -28,7 +28,7 @@ fn solve(input: &str) -> Result> { fabric .entry(square_inch) .and_modify(|ids| ids.push(claim.id)) - .or_insert(vec![claim.id]); + .or_insert_with(|| vec![claim.id]); } fabric }, @@ -37,8 +37,7 @@ fn solve(input: &str) -> Result> { let output = values .iter() .map(|ids| ids[0]) - .filter(|id| !values.iter().any(|ids| ids.len() > 1 && ids.contains(id))) - .next() + .find(|id| !values.iter().any(|ids| ids.len() > 1 && ids.contains(id))) .unwrap() .to_string(); Ok(output)