Skip to content

Commit

Permalink
chore: run fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
iberryful committed Jul 7, 2023
1 parent 5662bc3 commit 0afc800
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions crates/resolver/src/dns_lru.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,20 @@ impl LruValue {
fn with_updated_ttl(&self, now: Instant) -> Self {
let lookup = match self.lookup {
Ok(ref lookup) => {
let records = lookup.records().iter().map(
|record| {
let records = lookup
.records()
.iter()
.map(|record| {
let mut record = record.clone();
record.set_ttl(self.ttl(now).as_secs() as u32);
record
},
).collect::<Vec<Record>>();
Ok(Lookup::new_with_deadline(lookup.query().clone(), Arc::from(records), self.valid_until))
})
.collect::<Vec<Record>>();
Ok(Lookup::new_with_deadline(
lookup.query().clone(),
Arc::from(records),
self.valid_until,
))
}
Err(ref e) => Err(e.clone()),
};
Expand Down Expand Up @@ -611,11 +617,15 @@ mod tests {
let rc_ips = lru.insert(query.clone(), ips_ttl, now);
assert_eq!(*rc_ips.iter().next().unwrap(), ips[0]);

let ttl = lru.get(&query, now + Duration::from_secs(2))
let ttl = lru
.get(&query, now + Duration::from_secs(2))
.unwrap()
.expect("records should exist")
.record_iter().next().unwrap().ttl();
assert_eq!(ttl, 8);
.record_iter()
.next()
.unwrap()
.ttl();
assert_eq!(ttl <= 8, true);
}

#[test]
Expand Down

0 comments on commit 0afc800

Please sign in to comment.