NLnetLabs / domain

A DNS library for Rust.
https://nlnetlabs.nl/projects/domain/about/
BSD 3-Clause "New" or "Revised" License
355 stars 60 forks source link

Mistake in Dname::from_slice doc example #263

Closed zacknewman closed 9 months ago

zacknewman commented 9 months ago

Despite the documentation which states the slice must be in wire format (which of course means must contain the root label among other things), the example provided for Dname::from_slice leads to an Err due to the missing root label. Specifically, the example should be changed to Dname::from_slice(b"\x07example\x03com\x00");; or if that was intentional to show that it's an error, it should be changed to something like assert!(Dname::from_slice(b"\x07example\x03com").map_or_else(|e| e == DnameError::RelativeName, |_| false)); emphasizing it's an error and why.

partim commented 9 months ago

Thanks for report! This is definitely a mistake in the documentation.