Adds deref call in assertion for hickory-client README example (#2173)

* Adds deref call in assertion

* Adds inner struct to pattern match

---------

Co-authored-by: Benjamin Fry <benjaminfry@me.com>
This commit is contained in:
Adrian Kappel 2024-05-18 14:40:03 -04:00 committed by GitHub
parent f868f8e27d
commit ede83dc7d6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -27,7 +27,7 @@ use std::str::FromStr;
use hickory_client::client::{Client, SyncClient};
use hickory_client::udp::UdpClientConnection;
use hickory_client::op::DnsResponse;
use hickory_client::rr::{DNSClass, Name, RData, Record, RecordType};
use hickory_client::rr::{rdata::A, DNSClass, Name, RData, Record, RecordType};
let address = "8.8.8.8:53".parse().unwrap();
let conn = UdpClientConnection::new(address).unwrap();
@ -49,7 +49,7 @@ let answers: &[Record] = response.answers();
// Records are generic objects which can contain any data.
// In order to access it we need to first check what type of record it is
// In this case we are interested in A, IPv4 address
if let Some(RData::A(ref ip)) = answers[0].data() {
if let Some(RData::A(A(ref ip))) = answers[0].data() {
assert_eq!(*ip, Ipv4Addr::new(93, 184, 215, 14))
} else {
assert!(false, "unexpected result")