Skip to content

BufferedReader's fill() doesn't fill the buffer #11372

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

Closed
Florob opened this issue Jan 7, 2014 · 0 comments · Fixed by #11375
Closed

BufferedReader's fill() doesn't fill the buffer #11372

Florob opened this issue Jan 7, 2014 · 0 comments · Fixed by #11375

Comments

@Florob
Copy link
Contributor

Florob commented Jan 7, 2014

The fill() method of BufferedReader does not fill the internal buffer, unless the buffer is completely empty. This does not match the description in the Buffer trait. One case where this can cause problems is when using read_char(), e.g.:

fn main() {
    let mut s = "a".repeat(64*1024-1);
    s.push_char('ß');

    let rdr = std::io::mem::MemReader::new(s.into_bytes());
    let mut rdr = std::io::buffered::BufferedReader::new(rdr);

    rdr.fill();
    rdr.consume(64*1024-2);

    println!("{}", rdr.read_char()); // Some('a')
    println!("{}", rdr.read_char()); // None, should be Some('ß')
    println!("{}", rdr.read_char()); // None
}
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

Successfully merging a pull request may close this issue.

1 participant