diff options
| author | Corey Farwell <coreyf@rwell.org> | 2017-03-19 10:18:19 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-03-19 10:18:19 -0400 |
| commit | d74c528f3a6db6a220c393690f16713b2f33bc54 (patch) | |
| tree | 8192c40c11132c31d7601f2f12a4537a2d4b6186 /src/libstd/net | |
| parent | f2290dab9a1261749a99c1a57ff7bd09d448a9f9 (diff) | |
| parent | 50cede0d31e74d271d94eb6df85988bc9e05c120 (diff) | |
| download | rust-d74c528f3a6db6a220c393690f16713b2f33bc54.tar.gz rust-d74c528f3a6db6a220c393690f16713b2f33bc54.zip | |
Rollup merge of #40590 - z1mvader:master, r=steveklabnik
documented order of conversion between u32 an ipv4addr This fixes https://github.com/rust-lang/rust/issues/40118
Diffstat (limited to 'src/libstd/net')
| -rw-r--r-- | src/libstd/net/ip.rs | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/libstd/net/ip.rs b/src/libstd/net/ip.rs index 5d6e8d319d7..24e0e6f3fa6 100644 --- a/src/libstd/net/ip.rs +++ b/src/libstd/net/ip.rs @@ -636,6 +636,7 @@ 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). fn from(ip: Ipv4Addr) -> u32 { let ip = ip.octets(); ((ip[0] as u32) << 24) + ((ip[1] as u32) << 16) + ((ip[2] as u32) << 8) + (ip[3] as u32) @@ -644,6 +645,7 @@ 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). fn from(ip: u32) -> Ipv4Addr { Ipv4Addr::new((ip >> 24) as u8, (ip >> 16) as u8, (ip >> 8) as u8, ip as u8) } |
