docs: unwrap correctness docs

Describe the possible reasons a socket recvfrom() would cause a panic.
pull/24376/head
Dom Dwyer 2023-07-10 14:01:11 +02:00
parent 991692d2fb
commit 060f1b2ed6
No known key found for this signature in database
GPG Key ID: E4C40DBD9157879A
1 changed files with 7 additions and 1 deletions

View File

@ -319,7 +319,13 @@ where
/// Wait for a UDP datagram to become ready, and read it entirely into `buf`.
async fn recv(socket: &UdpSocket, buf: &mut BytesMut) -> (usize, SocketAddr) {
let (n_bytes, addr) = socket.recv_buf_from(buf).await.expect("frame buffer maxed");
let (n_bytes, addr) = socket
.recv_buf_from(buf)
.await
// These errors are libc's recvfrom() or converting the kernel-provided
// socket structure to rust's SocketAddr - neither should ever happen.
.expect("invalid recvfrom");
trace!(%addr, n_bytes, "socket read");
(n_bytes, addr)
}