From adf67270723e4abca08416385f62128d77652f2b Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Thu, 22 Aug 2019 09:02:36 +0200 Subject: [PATCH] [clippy] api-test: generalize HashSet impls and closure cleanups Signed-off-by: Wolfgang Bumiller --- api-test/src/schema/string_list.rs | 4 +--- api-test/src/schema/string_set.rs | 4 ++-- api-test/src/schema/tools.rs | 4 ++-- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/api-test/src/schema/string_list.rs b/api-test/src/schema/string_list.rs index 3aac603d..19608bac 100644 --- a/api-test/src/schema/string_list.rs +++ b/api-test/src/schema/string_list.rs @@ -62,9 +62,7 @@ impl<'de> serde::de::Visitor<'de> for StringListVisitor { } fn visit_seq>(self, mut seq: A) -> Result { - let mut out = seq - .size_hint() - .map_or_else(Vec::new, |size| Vec::with_capacity(size)); + let mut out = seq.size_hint().map_or_else(Vec::new, Vec::with_capacity); loop { match seq.next_element::()? { Some(el) => out.push(el), diff --git a/api-test/src/schema/string_set.rs b/api-test/src/schema/string_set.rs index 891287ec..20133e4d 100644 --- a/api-test/src/schema/string_set.rs +++ b/api-test/src/schema/string_set.rs @@ -13,7 +13,7 @@ pub trait ForEachStr { F: FnMut(&str) -> Result<(), Error>; } -impl ForEachStr for HashSet { +impl ForEachStr for HashSet { fn for_each_str(&self, mut func: F) -> Result<(), Error> where F: FnMut(&str) -> Result<(), Error>, @@ -69,7 +69,7 @@ impl<'de> serde::de::Visitor<'de> for StringSetVisitor { fn visit_seq>(self, mut seq: A) -> Result { let mut out = seq .size_hint() - .map_or_else(HashSet::new, |size| HashSet::with_capacity(size)); + .map_or_else(HashSet::new, HashSet::with_capacity); loop { match seq.next_element::()? { Some(el) => out.insert(el), diff --git a/api-test/src/schema/tools.rs b/api-test/src/schema/tools.rs index 376ea2e3..83376698 100644 --- a/api-test/src/schema/tools.rs +++ b/api-test/src/schema/tools.rs @@ -39,13 +39,13 @@ impl StringContainer for Option> { } } -impl StringContainer for HashSet { +impl StringContainer for HashSet { fn all bool>(&self, pred: F) -> bool { self.iter().all(|s| pred(s)) } } -impl StringContainer for Option> { +impl StringContainer for Option> { fn all bool>(&self, pred: F) -> bool { self.as_ref() .map(|c| StringContainer::all(c, pred))