Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from
May 18, 2024

Conversation

akappel
Copy link
Contributor

@akappel akappel commented Mar 22, 2024

I pasted the example code from the hickory-client README example into a brand new project. Building gave the following error message:

error[E0308]: mismatched types
  --> src/main.rs:30:25
   |
30 |         assert_eq!(*ip, Ipv4Addr::new(93, 184, 216, 34))
   |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `A`, found `Ipv4Addr`
   |
help: try wrapping the expression in `hickory_client::rr::rdata::A`
   |
30 |         assert_eq!(*ip, hickory_client::rr::rdata::A(Ipv4Addr::new(93, 184, 216, 34)))
   |                         +++++++++++++++++++++++++++++                               +

For more information about this error, try `rustc --explain E0308`.

It looks like we need an extra deref *, or a call to .deref(). I opted for the latter. The code compiles as expected now. Please let me know if there is a preference for the former solution instead.

@akappel akappel changed the title Adds deref call in assertion Adds deref call in assertion for hickory-client README example Mar 22, 2024
@akappel
Copy link
Contributor Author

akappel commented Mar 22, 2024

I also just realized that ip might be misleading, since the ref is &A. Maybe I should change the variable name to a_rdata?

@djc
Copy link
Collaborator

djc commented Mar 22, 2024

Thanks for the PR!

I think the right fix here is more like making the pattern something like Some(RData::A(A(ip))).

@akappel
Copy link
Contributor Author

akappel commented Mar 22, 2024

@djc - makes sense! done!

Copy link
Member

@bluejekyll bluejekyll left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for cleaning this up.

@bluejekyll bluejekyll merged commit ede83dc into hickory-dns:main May 18, 2024
3 checks passed
@bluejekyll
Copy link
Member

Sorry, had to squash merge this after fixing a merge conflict.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants