mirror of
https://git.proxmox.com/git/proxmox
synced 2025-05-06 02:05:58 +00:00
[clippy] api-test: generalize HashSet impls and closure cleanups
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
4a33af4387
commit
adf6727072
@ -62,9 +62,7 @@ impl<'de> serde::de::Visitor<'de> for StringListVisitor {
|
||||
}
|
||||
|
||||
fn visit_seq<A: serde::de::SeqAccess<'de>>(self, mut seq: A) -> Result<Self::Value, A::Error> {
|
||||
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::<String>()? {
|
||||
Some(el) => out.push(el),
|
||||
|
@ -13,7 +13,7 @@ pub trait ForEachStr {
|
||||
F: FnMut(&str) -> Result<(), Error>;
|
||||
}
|
||||
|
||||
impl ForEachStr for HashSet<String> {
|
||||
impl<S: std::hash::BuildHasher> ForEachStr for HashSet<String, S> {
|
||||
fn for_each_str<F>(&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<A: serde::de::SeqAccess<'de>>(self, mut seq: A) -> Result<Self::Value, A::Error> {
|
||||
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::<String>()? {
|
||||
Some(el) => out.insert(el),
|
||||
|
@ -39,13 +39,13 @@ impl StringContainer for Option<Vec<String>> {
|
||||
}
|
||||
}
|
||||
|
||||
impl StringContainer for HashSet<String> {
|
||||
impl<S: std::hash::BuildHasher> StringContainer for HashSet<String, S> {
|
||||
fn all<F: Fn(&str) -> bool>(&self, pred: F) -> bool {
|
||||
self.iter().all(|s| pred(s))
|
||||
}
|
||||
}
|
||||
|
||||
impl StringContainer for Option<HashSet<String>> {
|
||||
impl<S: std::hash::BuildHasher> StringContainer for Option<HashSet<String, S>> {
|
||||
fn all<F: Fn(&str) -> bool>(&self, pred: F) -> bool {
|
||||
self.as_ref()
|
||||
.map(|c| StringContainer::all(c, pred))
|
||||
|
Loading…
Reference in New Issue
Block a user