You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
rust-ripgrep/0001-Update-to-memmap-0.6.p...

40 lines
1.3 KiB

From e7e087a5eee08454e4d90f2fb4e0714c7d38a905 Mon Sep 17 00:00:00 2001
From: Dan Burkert <dan@danburkert.com>
Date: Sat, 28 Oct 2017 15:32:43 -0700
Subject: [PATCH] Update to memmap 0.6
`memmap` 0.6.0 introduces major API changes in anticipation of a 1.0
release. See https://github.com/danburkert/memmap-rs/releases/tag/0.6.0
for more information. CC danburkert/memmap-rs#33.
---
src/worker.rs | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/worker.rs b/src/worker.rs
index 51b7f64..9aa0fdc 100644
--- a/src/worker.rs
+++ b/src/worker.rs
@@ -5,7 +5,7 @@ use std::path::Path;
use encoding_rs::Encoding;
use grep::Grep;
use ignore::DirEntry;
-use memmap::{Mmap, Protection};
+use memmap::Mmap;
use termcolor::WriteColor;
use decoder::DecodeReader;
@@ -290,8 +290,8 @@ impl Worker {
// regular read calls.
return self.search(printer, path, file);
}
- let mmap = try!(Mmap::open(file, Protection::Read));
- let buf = unsafe { mmap.as_slice() };
+ let mmap = unsafe { try!(Mmap::map(file)) };
+ let buf = &*mmap;
if buf.len() >= 3 && Encoding::for_bom(buf).is_some() {
// If we have a UTF-16 bom in our memory map, then we need to fall
// back to the stream reader, which will do transcoding.
--
2.15.0