Use the bytecount crate for fast line counting.

Fixes #128
This commit is contained in:
Andre Bogus
2016-09-23 04:59:25 +02:00
committed by Andrew Gallant
parent 32db773d51
commit 02de97b8ce
5 changed files with 26 additions and 82 deletions

View File

@@ -43,9 +43,14 @@ impl WorkDir {
/// Create a new file with the given name and contents in this directory.
pub fn create<P: AsRef<Path>>(&self, name: P, contents: &str) {
self.create_bytes(name, contents.as_bytes());
}
/// Create a new file with the given name and contents in this directory.
pub fn create_bytes<P: AsRef<Path>>(&self, name: P, contents: &[u8]) {
let path = self.dir.join(name);
let mut file = nice_err(&path, File::create(&path));
nice_err(&path, file.write_all(contents.as_bytes()));
nice_err(&path, file.write_all(contents));
nice_err(&path, file.flush());
}