Skip to content

Commit aca0258

Browse files
committed
Use u32::from_le_bytes to fix a FIXME
1 parent 7637cbb commit aca0258

File tree

1 file changed

+1
-9
lines changed

1 file changed

+1
-9
lines changed

library/std/src/net/ip.rs

+1-9
Original file line numberDiff line numberDiff line change
@@ -319,15 +319,7 @@ impl Ipv4Addr {
319319
#[stable(feature = "rust1", since = "1.0.0")]
320320
#[rustc_const_stable(feature = "const_ipv4", since = "1.32.0")]
321321
pub const fn new(a: u8, b: u8, c: u8, d: u8) -> Ipv4Addr {
322-
// FIXME: should just be u32::from_be_bytes([a, b, c, d]),
323-
// once that method is no longer rustc_const_unstable
324-
Ipv4Addr {
325-
inner: c::in_addr {
326-
s_addr: u32::to_be(
327-
((a as u32) << 24) | ((b as u32) << 16) | ((c as u32) << 8) | (d as u32),
328-
),
329-
},
330-
}
322+
Ipv4Addr { inner: c::in_addr { s_addr: u32::from_le_bytes([a, b, c, d]) } }
331323
}
332324

333325
/// An IPv4 address with the address pointing to localhost: 127.0.0.1.

0 commit comments

Comments
 (0)