1 extern crate memmap2;
2 
3 use std::env;
4 use std::fs::File;
5 use std::io::{self, Write};
6 
7 use memmap2::Mmap;
8 
9 /// Output a file's contents to stdout. The file path must be provided as the first process
10 /// argument.
main()11 fn main() {
12     let path = env::args()
13         .nth(1)
14         .expect("supply a single path as the program argument");
15 
16     let file = File::open(path).expect("failed to open the file");
17 
18     let mmap = unsafe { Mmap::map(&file).expect("failed to map the file") };
19 
20     io::stdout()
21         .write_all(&mmap[..])
22         .expect("failed to output the file contents");
23 }
24