1 unstable release

Uses old Rust 2015

0.0.1 Jul 11, 2016

#5 in #eof

Download history 187/week @ 2023-12-06 237/week @ 2023-12-13 288/week @ 2023-12-20 347/week @ 2023-12-27 161/week @ 2024-01-03 235/week @ 2024-01-10 230/week @ 2024-01-17 108/week @ 2024-01-24 214/week @ 2024-01-31 240/week @ 2024-02-07 253/week @ 2024-02-14 338/week @ 2024-02-21 239/week @ 2024-02-28 172/week @ 2024-03-06 191/week @ 2024-03-13 277/week @ 2024-03-20

887 downloads per month
Used in 258 crates (via pod)

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