disallow some methods from itertools

This commit is contained in:
Luna Yao
2026-04-06 18:28:30 +02:00
parent 6af62e939e
commit 5a8a1d3e6b
11 changed files with 44 additions and 40 deletions
+11 -3
View File
@@ -6,7 +6,7 @@ use crate::proto::dns::DnsNodeMgrRpc;
use crate::proto::dns::{DnsSnapshot, HeartbeatRequest, HeartbeatResponse};
use crate::proto::rpc_types;
use crate::proto::rpc_types::controller::BaseController;
use crate::utils::{DeterministicDigest, MapTryInto};
use crate::utils::DeterministicDigest;
use anyhow::Error;
use hickory_server::authority::Catalog;
use itertools::Itertools;
@@ -30,8 +30,16 @@ impl TryFrom<&DnsSnapshot> for DnsNodeInfo {
Ok(Self {
digest: value.digest(),
zones: (&value.zones).try_into()?,
addresses: value.addresses.iter().map_try_into().try_collect()?,
listeners: value.listeners.iter().map_try_into().try_collect()?,
addresses: value
.addresses
.iter()
.map(TryInto::try_into)
.collect::<Result<_, _>>()?,
listeners: value
.listeners
.iter()
.map(TryInto::try_into)
.collect::<Result<_, _>>()?,
})
}
}
+1 -2
View File
@@ -14,7 +14,6 @@ use crate::proto::rpc_types;
use crate::proto::rpc_types::controller::BaseController;
use crate::utils::DeterministicDigest;
use anyhow::Context;
use itertools::Itertools;
use moka::future::Cache;
use std::ops::Deref;
use std::sync::Arc;
@@ -53,7 +52,7 @@ impl DnsPeerMgrInner {
let zones = global_ctx
.dns_iter_zones()
.map_into()
.map(Into::into)
.chain(
self.peers
.iter()
+3 -4
View File
@@ -4,7 +4,6 @@ use crate::proto::utils::RepeatedMessageModel;
use anyhow::{anyhow, Error};
use hickory_proto::xfer::Protocol;
use hickory_resolver::config::{NameServerConfig, NameServerConfigGroup};
use itertools::Itertools;
use serde_with::{DeserializeFromStr, SerializeDisplay};
use std::fmt::{Display, Formatter};
use std::net::{IpAddr, SocketAddr};
@@ -129,7 +128,7 @@ pub type NameServerAddrGroup = RepeatedMessageModel<NameServerAddr>;
impl From<NameServerAddrGroup> for NameServerConfigGroup {
fn from(value: NameServerAddrGroup) -> Self {
value.into_iter().map_into().collect_vec().into()
value.into_iter().map(Into::into).collect::<Vec<_>>().into()
}
}
@@ -138,8 +137,8 @@ impl From<NameServerConfigGroup> for NameServerAddrGroup {
value
.into_inner()
.into_iter()
.map_into()
.collect_vec()
.map(Into::into)
.collect::<Vec<_>>()
.into()
}
}
+1 -2
View File
@@ -1,6 +1,5 @@
use hickory_proto::rr::LowerName;
use idna::AsciiDenyList;
use itertools::Itertools;
pub mod addr;
pub mod authority;
@@ -24,7 +23,7 @@ pub fn sanitize(name: &str) -> String {
.to_string()
})
.filter(|label| !label.is_empty())
.collect_vec()
.collect::<Vec<_>>()
.join(".");
name.truncate(253);
if dot {
+7 -8
View File
@@ -3,7 +3,6 @@ use crate::dns::utils::addr::NameServerAddr;
use crate::dns::utils::authority::ArcAuthority;
use crate::proto;
use crate::proto::utils::RepeatedMessageModel;
use crate::utils::MapTryInto;
use hickory_proto::rr::{LowerName, RecordSet, RrKey};
use hickory_proto::serialize::txt::Parser;
use hickory_resolver::config::ResolverOpts;
@@ -13,7 +12,7 @@ use hickory_server::authority::ZoneType;
use hickory_server::store::forwarder::{ForwardAuthority, ForwardConfig};
use hickory_server::store::in_memory::InMemoryAuthority;
use indexmap::IndexMap;
use itertools::{chain, Itertools};
use itertools::chain;
use std::collections::BTreeMap;
use std::sync::Arc;
use uuid::Uuid;
@@ -96,9 +95,9 @@ impl TryFrom<&proto::dns::ZoneData> for Zone {
let servers = value
.forwarders
.iter()
.map_try_into::<NameServerAddr>()
.map_ok(Into::into)
.try_collect::<_, Vec<_>, _>()?;
.map(TryInto::<NameServerAddr>::try_into)
.map(|a| a.map(Into::into))
.collect::<Result<Vec<_>, _>>()?;
let forward = (!servers.is_empty()).then_some(ForwardConfig {
name_servers: servers.into(),
options: None,
@@ -126,8 +125,8 @@ impl From<Zone> for proto::dns::ZoneData {
.forward
.into_iter()
.flat_map(|f| f.name_servers.into_inner().into_iter())
.map_into::<NameServerAddr>()
.map_into()
.map(Into::<NameServerAddr>::into)
.map(Into::into)
.collect();
Self {
@@ -365,7 +364,7 @@ mod tests {
))?]
.into();
let authorities = zones.iter_authorities().collect_vec();
let authorities = zones.iter_authorities().collect::<Vec<_>>();
assert_eq!(authorities.len(), 2);
Ok(())