From aca025823221f2c7d52fcc8893f69f5042edafbc Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Mon, 3 Aug 2020 06:51:41 +0000 Subject: [PATCH] Use u32::from_le_bytes to fix a FIXME --- library/std/src/net/ip.rs | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/library/std/src/net/ip.rs b/library/std/src/net/ip.rs index a64b43ca3ad45..6fdf635039f68 100644 --- a/library/std/src/net/ip.rs +++ b/library/std/src/net/ip.rs @@ -319,15 +319,7 @@ impl Ipv4Addr { #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_stable(feature = "const_ipv4", since = "1.32.0")] pub const fn new(a: u8, b: u8, c: u8, d: u8) -> Ipv4Addr { - // FIXME: should just be u32::from_be_bytes([a, b, c, d]), - // once that method is no longer rustc_const_unstable - Ipv4Addr { - inner: c::in_addr { - s_addr: u32::to_be( - ((a as u32) << 24) | ((b as u32) << 16) | ((c as u32) << 8) | (d as u32), - ), - }, - } + Ipv4Addr { inner: c::in_addr { s_addr: u32::from_le_bytes([a, b, c, d]) } } } /// An IPv4 address with the address pointing to localhost: 127.0.0.1.