Skip to content

Document that UdpSocket::recv and recv_from do not read from the buffer #657

@dtolnay

Description

@dtolnay
fn recv(&self, buf: &mut [u8]) -> Result<usize>;
fn recv_from(&self, buf: &mut [u8]) -> Result<(usize, SocketAddr)>;

It is important for these to document that they only write to the buffer, not read from it, because that means it is safe to pass an uninitialized buffer. It would be wasteful to construct a buffer, initialize it to contain all 0 bytes, and pass it to UdpSocket.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions