Skip to content

read_to_string error handling is inconsistent with std #2702

@dfoxfranke

Description

@dfoxfranke

AsyncReadExt::read_to_string leaves buf empty if it encounters invalid UTF-8. This is inconsistent with the behavior of std::io::Read::read_to_string, which will truncate it to original length (i.e. leave it unchanged).

Relatedly, the performance of this method could be improved. Currently it validates the entire string; it is only necessary to validate the newly-read portion since the original portion is already guaranteed to be valid.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ioArea: futures::io

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions