memmap 0.2.0

Cross-platform Rust API for memory-mapped file IO
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
extern crate memmap;

use std::env;
use std::io::{self, Write};

use memmap::{Mmap, Protection};

/// Output a file's contents to stdout. The file path must be provided as the first process
/// argument.
fn main() {
    let path = env::args().nth(1).expect("supply a single path as the program argument");

    let mmap = Mmap::open_path(path, Protection::Read).unwrap();

    io::stdout().write_all(unsafe { mmap.as_slice() }).unwrap();
}