Skip to content

Commit 8346459

Browse files
committed
Simplify Ipv6Addr::from(octets) to not use unsafe
1 parent d45a703 commit 8346459

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

src/libstd/net/ip.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
use cmp::Ordering;
1717
use fmt;
1818
use hash;
19-
use mem;
2019
use sys::net::netc as c;
2120
use sys_common::{AsInner, FromInner};
2221

@@ -1429,8 +1428,7 @@ impl From<u128> for Ipv6Addr {
14291428
#[stable(feature = "ipv6_from_octets", since = "1.9.0")]
14301429
impl From<[u8; 16]> for Ipv6Addr {
14311430
fn from(octets: [u8; 16]) -> Ipv6Addr {
1432-
let mut inner: c::in6_addr = unsafe { mem::zeroed() };
1433-
inner.s6_addr = octets;
1431+
let inner = c::in6_addr { s6_addr: octets };
14341432
Ipv6Addr::from_inner(inner)
14351433
}
14361434
}

0 commit comments

Comments
 (0)