From f862d36afd905cb245eadc51e077c2575d588162 Mon Sep 17 00:00:00 2001 From: Cole Mickens Date: Mon, 18 Sep 2023 18:06:39 +0200 Subject: [PATCH] fns: remove hack; limit async closure capture to zone->id --- src/fns.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/fns.rs b/src/fns.rs index 81ff477..ffb07d3 100644 --- a/src/fns.rs +++ b/src/fns.rs @@ -72,19 +72,18 @@ pub async fn get_records( let params = ListZones { params: ListZonesParams::default(), }; - let zones = client.request(¶ms); - // HACK: make a second call since dns::Zone does not implement Clone upstream - let zones2 = client.request(¶ms).await?.result; + let zones = client.request(¶ms).await?.result; - let mut handles = Vec::with_capacity(zones2.len()); - let mut records = Vec::with_capacity(zones2.len() * 10); + let mut handles = Vec::with_capacity(zones.len()); + let mut records = Vec::with_capacity(zones.len() * 10); - for zone in zones.await?.result { + for zone in &zones { let client = client.clone(); + let zone_id = zone.id.to_string(); handles.push(tokio::spawn(async move { client .request(&ListDnsRecords { - zone_identifier: &zone.id, + zone_identifier: &zone_id, params: ListDnsRecordsParams::default(), }) .await @@ -117,7 +116,7 @@ pub async fn get_records( .map(|r| { ( r.to_owned(), - zones2 + zones .iter() .find(|z| r.contains(&z.name)) .map(|z| z.id.to_owned()),