Skip to content

BufReader .consume() confuses the Reader seek point when the buffer is empty #23196

Closed
@jorisgio

Description

@jorisgio

The behavior of .consume when the buffer is empty is weird :

let mut f = BufReader::new(Cursor::new(vec![65, 255, 42]));
f.consume(1);
let x = &mut [0; 1];
println!("{}", f.read(x).unwrap()); // prints 0

while :

let mut f = BufReader::new(Cursor::new(vec![65, 255, 42]));
let x = &mut [0; 1];
f.read(x).unwrap();
f.consume(1);
println!("{}", f.read(x).unwrap()); // prints 1, x[0] is 42

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