Skip to content

io::reader::read_byte for *FILE behaves surprisingly on EOF #2960

@catamorphism

Description

@catamorphism

In the io::reader impl for *libc::FILE, read_byte returns -1 on EOF. This is not surprising since it just calls libc::fgetc, but it's arguably wrong since callers are presumably going to use eof() to check for EOF and thus shouldn't have to worry about dealing with a bogus trailing -1.

Instead, perhaps it could fail? I'm not really sure. Or maybe this is supposed to be a low-level interface, but it still seems weird for Rust code to have to deal with sentinel values like this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions