-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Clarify network byte order conversions for integer / IP address conversions. #49418
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
Conversation
r? @TimNN (rust_highfive has picked a reviewer for you, use r? to override) |
@@ -769,7 +769,16 @@ impl FromInner<c::in_addr> for Ipv4Addr { | |||
|
|||
#[stable(feature = "ip_u32", since = "1.1.0")] | |||
impl From<Ipv4Addr> for u32 { | |||
/// It performs the conversion in network order (big-endian). | |||
/// Convert an `Ipv4Addr` into a host byte order `u32`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
admittedly i'm not sure what this terminology should be here w.r.t. the removal of 'network order' and addition of 'host byte order'. i just took it as a suggestion from this thread. might be nice to get input from the libs/docs team here @rust-lang/libs @rust-lang/docs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To me the new wording seems good, and more easily understandable than the old version, although I'd be curious to hear what other people think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. The new wording looks good, and this is how I'd expect this function to behave.
src/libstd/net/ip.rs
Outdated
@@ -778,21 +787,48 @@ impl From<Ipv4Addr> for u32 { | |||
|
|||
#[stable(feature = "ip_u32", since = "1.1.0")] | |||
impl From<u32> for Ipv4Addr { | |||
/// It performs the conversion in network order (big-endian). | |||
/// Convert an host byte order `u32` into an `Ipv4Addr`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I think this should be "a host byte [...]" (At least it should be consistent with the doc comment above).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch! addressed in the latest force push
…rsions. Opened primarily to address rust-lang#48819.
e95ccc7
to
b89fb71
Compare
Why doesn't this include the |
ran out of time when i made this branch. we can expand to the the u128 impls in a future pr |
@bors r+ rollup |
📌 Commit b89fb71 has been approved by |
Clarify network byte order conversions for integer / IP address conversions. Opened primarily to address #48819. Also added a few other conversion docs/examples.
☀️ Test successful - status-appveyor, status-travis |
Opened primarily to address #48819.
Also added a few other conversion docs/examples.