Skip to content

Socket::recv_from taking a &mut [u8] #223

Closed
@danielrh

Description

@danielrh

Starting in version 0.4.0 there's no safe way to pass a &mut [u8] into recv_from, since RecvFrom takes &mut [MaybeUninitialized<u8>] and rustc does not understand if the library potentially writes uninitalized bytes to the buffer.

Would it be possible to return the signature of the function to the way it was in 0.3.0 so that we can safely call recv_from? Perhaps a recv_from_uninitialized_with_options would be something useful for hyper-tuned applications.

Currently the only way I can see to interact with recv_from when I have a &mut [u8] is to use transmute, which is very difficult to pass code review with and difficult to reason about.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions