Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ghost opened this issue Sep 27, 2016 · 0 comments
Closed

Comments

@ghost
Copy link

ghost commented Sep 27, 2016

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"`)'
bors added a commit that referenced this issue Sep 28, 2016
[std::io::Chain] Mark first as done only when reading into non-zero length buffer.

Fixes #36771.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant