File tree Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ lazy_static = "1"
17
17
libc = " 0.2"
18
18
onig = { version = " 3" , optional = true }
19
19
libpcre-sys = { version = " 0.2" , optional = true }
20
- memmap = " 0.2 "
20
+ memmap = " 0.6 "
21
21
regex = { version = " 0.2.0" , path = " .." , features = [" simd-accel" ] }
22
22
regex-syntax = { version = " 0.4.0" , path = " ../regex-syntax" }
23
23
serde = " 1"
Original file line number Diff line number Diff line change @@ -26,10 +26,11 @@ extern crate serde;
26
26
#[ macro_use]
27
27
extern crate serde_derive;
28
28
29
+ use std:: fs:: File ;
29
30
use std:: str;
30
31
31
32
use docopt:: Docopt ;
32
- use memmap:: { Mmap , Protection } ;
33
+ use memmap:: Mmap ;
33
34
34
35
mod ffi;
35
36
@@ -69,8 +70,10 @@ fn main() {
69
70
. and_then ( |d| d. deserialize ( ) )
70
71
. unwrap_or_else ( |e| e. exit ( ) ) ;
71
72
72
- let mmap = Mmap :: open_path ( & args. arg_file , Protection :: Read ) . unwrap ( ) ;
73
- let haystack = unsafe { str:: from_utf8_unchecked ( mmap. as_slice ( ) ) } ;
73
+ let mmap = unsafe {
74
+ Mmap :: map ( & File :: open ( & args. arg_file ) . unwrap ( ) ) . unwrap ( )
75
+ } ;
76
+ let haystack = unsafe { str:: from_utf8_unchecked ( & mmap) } ;
74
77
75
78
println ! ( "{}" , args. count( & haystack) ) ;
76
79
}
You can’t perform that action at this time.
0 commit comments