1 unstable release

Uses old Rust 2015

0.0.1 Jul 11, 2016

#5 in #eof

Download history 260/week @ 2024-02-26 171/week @ 2024-03-04 192/week @ 2024-03-11 205/week @ 2024-03-18 579/week @ 2024-03-25 551/week @ 2024-04-01 278/week @ 2024-04-08 320/week @ 2024-04-15 431/week @ 2024-04-22 580/week @ 2024-04-29 422/week @ 2024-05-06 390/week @ 2024-05-13 383/week @ 2024-05-20 311/week @ 2024-05-27 623/week @ 2024-06-03 277/week @ 2024-06-10

1,652 downloads per month
Used in 260 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