Skip to content

Commit

Permalink
Adds deref call in assertion for hickory-client README example (#2173)
Browse files Browse the repository at this point in the history
* Adds deref call in assertion

* Adds inner struct to pattern match

---------

Co-authored-by: Benjamin Fry <benjaminfry@me.com>
  • Loading branch information
akappel and bluejekyll committed May 18, 2024
1 parent f868f8e commit ede83dc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions crates/client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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")
Expand Down

0 comments on commit ede83dc

Please sign in to comment.