1 unstable release

Uses old Rust 2015

0.0.1 Jul 11, 2016

#6 in #eof

Download history 236/week @ 2024-11-15 193/week @ 2024-11-22 306/week @ 2024-11-29 552/week @ 2024-12-06 351/week @ 2024-12-13 387/week @ 2024-12-20 61/week @ 2024-12-27 212/week @ 2025-01-03 308/week @ 2025-01-10 334/week @ 2025-01-17 268/week @ 2025-01-24 194/week @ 2025-01-31 273/week @ 2025-02-07 286/week @ 2025-02-14 328/week @ 2025-02-21 262/week @ 2025-02-28

1,183 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