refactor: remove panic-prone unwrap and expect calls

This commit is contained in:
lbl
2026-08-23 12:04:40 +08:00
parent 2100ec1ca5
commit c2fd1ff870
18 changed files with 161 additions and 128 deletions
+2 -4
View File
@@ -228,11 +228,9 @@ fn bind_udp(
default_interface: &Option<LocalInterface>,
) -> io::Result<UdpSocket> {
let addr: SocketAddr = if name_server.is_ipv4() {
"0.0.0.0:0"
.parse()
.expect("valid IPv4 socket address literal")
SocketAddr::from(([0, 0, 0, 0], 0))
} else {
"[::]:0".parse().expect("valid IPv6 socket address literal")
SocketAddr::from(([0; 8], 0))
};
let socket = rust_p2p_core::socket::bind_udp(addr, default_interface.as_ref())?;
UdpSocket::from_std(socket.into())