-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Closed
Description
I open a file containing two bytes. Check EOF - false. Read two bytes, check EOF - false, read one byte - EOF error.
Is there a problem with File.eof() here, or am I doing something wrong?
use std::io::File;
// Create testfile using:
// echo -n -e '\x66\x6f' > testfile
fn main() {
let mut fh = File::open(&Path::new("testfile")).unwrap();
println!("{}", fh.eof()); // false
println!("{}", fh.read_le_u16().unwrap()); // 28518
println!("{}", fh.eof()); // false
println!("{}", fh.read_u8().unwrap());
// task '<main>' failed at 'called `Result::unwrap()`
// on an `Err` value: couldn't read file (end of file; path=testfile)'
}
Metadata
Metadata
Assignees
Labels
No labels