Skip to content

Commit a26c37b

Browse files
authored
Rollup merge of rust-lang#40590 - z1mvader:master, r=steveklabnik
documented order of conversion between u32 an ipv4addr This fixes rust-lang#40118
2 parents 08c9ad1 + 50cede0 commit a26c37b

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/libstd/net/ip.rs

+2
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,7 @@ impl FromInner<c::in_addr> for Ipv4Addr {
636636

637637
#[stable(feature = "ip_u32", since = "1.1.0")]
638638
impl From<Ipv4Addr> for u32 {
639+
/// It performs the conversion in network order (big-endian).
639640
fn from(ip: Ipv4Addr) -> u32 {
640641
let ip = ip.octets();
641642
((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 {
644645

645646
#[stable(feature = "ip_u32", since = "1.1.0")]
646647
impl From<u32> for Ipv4Addr {
648+
/// It performs the conversion in network order (big-endian).
647649
fn from(ip: u32) -> Ipv4Addr {
648650
Ipv4Addr::new((ip >> 24) as u8, (ip >> 16) as u8, (ip >> 8) as u8, ip as u8)
649651
}

0 commit comments

Comments
 (0)