Skip to content

Commit 3c437e5

Browse files
authored
Rollup merge of rust-lang#73389 - lzutao:from, r=kennytm
Use `Ipv4Addr::from<[u8; 4]>` when possible Resolve this comment: rust-lang#73331 (comment)
2 parents 759547b + 0e6c333 commit 3c437e5

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

src/libstd/sys/hermit/net.rs

+2-8
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,7 @@ impl TcpStream {
147147
.map_err(|_| io::Error::new(ErrorKind::Other, "peer_addr failed"))?;
148148

149149
let saddr = match ipaddr {
150-
Ipv4(ref addr) => SocketAddr::new(
151-
IpAddr::V4(Ipv4Addr::new(addr.0[0], addr.0[1], addr.0[2], addr.0[3])),
152-
port,
153-
),
150+
Ipv4(ref addr) => SocketAddr::new(IpAddr::V4(Ipv4Addr::from(addr.0)), port),
154151
Ipv6(ref addr) => SocketAddr::new(IpAddr::V6(Ipv6Addr::from(addr.0)), port),
155152
_ => {
156153
return Err(io::Error::new(ErrorKind::Other, "peer_addr failed"));
@@ -227,10 +224,7 @@ impl TcpListener {
227224
let (handle, ipaddr, port) = abi::tcplistener::accept(self.0.port())
228225
.map_err(|_| io::Error::new(ErrorKind::Other, "accept failed"))?;
229226
let saddr = match ipaddr {
230-
Ipv4(ref addr) => SocketAddr::new(
231-
IpAddr::V4(Ipv4Addr::new(addr.0[0], addr.0[1], addr.0[2], addr.0[3])),
232-
port,
233-
),
227+
Ipv4(ref addr) => SocketAddr::new(IpAddr::V4(Ipv4Addr::from(addr.0)), port),
234228
Ipv6(ref addr) => SocketAddr::new(IpAddr::V6(Ipv6Addr::from(addr.0)), port),
235229
_ => {
236230
return Err(io::Error::new(ErrorKind::Other, "accept failed"));

0 commit comments

Comments
 (0)