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

Derive Eq for DnsContent #226

Open
ferrohd opened this issue Nov 10, 2023 · 0 comments · May be fixed by #227
Open

Derive Eq for DnsContent #226

ferrohd opened this issue Nov 10, 2023 · 0 comments · May be fixed by #227

Comments

@ferrohd
Copy link

ferrohd commented Nov 10, 2023

Currently, comparisons between DnsContent instances require explicit matching of the enum variants.

let dns1: DnsContent = ...;
let dns2: DnsContent = ...;

let is_same_record: bool = match (dns1, dns2) {
    (DnsContent::A { content: ip1 }, DnsContent::A { content: ip2 }) => ip1 == ip2,
    // ...
    _ => false
};

Deriving Eq (and therefore PartialEq), DnsContent instances can be compared using the == operator, providing a more ergonomic API to interact with DNS records.

let dns1: DnsContent = ...;
let dns2: DnsContent = ...;

let same_record: bool = dns1 == dns2;
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 a pull request may close this issue.

1 participant