Skip to content

std::io::Chain incorrectly assumes that Ok(0) returned from read indicates EOF. #36771

Closed
@ghost

Description

For example:

use std::io::{Cursor, Read};

fn main() {
    let mut reader = Cursor::new(
        b"A".to_owned()
    ).chain(
        Cursor::new(b"B".to_owned())
    );

    reader.read(&mut []).unwrap();
    let mut s = String::new();
    reader.read_to_string(&mut s).unwrap();
    assert_eq!("AB", s);
}

Results in:

thread 'main' panicked at 'assertion failed: `(left == right)` (left: `"AB"`, right: `"B"`)'

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