We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 08c9ad1 + 50cede0 commit a26c37bCopy full SHA for a26c37b
src/libstd/net/ip.rs
@@ -636,6 +636,7 @@ impl FromInner<c::in_addr> for Ipv4Addr {
636
637
#[stable(feature = "ip_u32", since = "1.1.0")]
638
impl From<Ipv4Addr> for u32 {
639
+ /// It performs the conversion in network order (big-endian).
640
fn from(ip: Ipv4Addr) -> u32 {
641
let ip = ip.octets();
642
((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 {
644
645
646
647
impl From<u32> for Ipv4Addr {
648
649
fn from(ip: u32) -> Ipv4Addr {
650
Ipv4Addr::new((ip >> 24) as u8, (ip >> 16) as u8, (ip >> 8) as u8, ip as u8)
651
}
0 commit comments