1 unstable release

Uses old Rust 2015

0.0.1 Jul 11, 2016

#7 in #eof

Download history 344/week @ 2024-08-30 360/week @ 2024-09-06 436/week @ 2024-09-13 514/week @ 2024-09-20 338/week @ 2024-09-27 208/week @ 2024-10-04 416/week @ 2024-10-11 298/week @ 2024-10-18 373/week @ 2024-10-25 296/week @ 2024-11-01 123/week @ 2024-11-08 236/week @ 2024-11-15 193/week @ 2024-11-22 306/week @ 2024-11-29 552/week @ 2024-12-06 324/week @ 2024-12-13

1,453 downloads per month
Used in 262 crates (2 directly)

MIT license

4KB
53 lines

read_exact

travis-badge release-badge docs-badge license-badge

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

Documentation

See the documentation for up to date information.


lib.rs:

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

Example

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
}

No runtime deps