Crate read_exact [] [src]

Provides a variant of read_exact that succeeds on EOF if no data has been read.


use std::io;
use std::io::prelude::*;
use std::fs::File;
use read_exact::ReadExactExt;

let mut f = try!(File::open("foo.txt"));
let mut buffer = [0; 10];
let success = try!(f.read_exact_or_eof(&mut buffer));
if success {
    // buffer is full
} else {
    // buffer contents unchanged, file was empty



An extension trait that applies to all std::io::Read types.