File tree 2 files changed +19
-8
lines changed 2 files changed +19
-8
lines changed Original file line number Diff line number Diff line change @@ -10,23 +10,18 @@ use std::fmt;
10
10
use std:: fs;
11
11
use std:: io:: { self , Read } ;
12
12
use std:: path;
13
- use std:: str;
14
13
15
14
use Predicate ;
16
15
17
16
#[ derive( Clone , Debug , PartialEq ) ]
18
- pub struct FileContent ( Vec < u8 > ) ;
17
+ struct FileContent ( Vec < u8 > ) ;
19
18
20
19
impl FileContent {
21
20
pub fn new ( path : & path:: Path ) -> io:: Result < FileContent > {
22
21
let mut buffer = Vec :: new ( ) ;
23
22
fs:: File :: open ( path) ?. read_to_end ( & mut buffer) ?;
24
23
Ok ( FileContent ( buffer) )
25
24
}
26
-
27
- pub fn utf8 ( & self ) -> Result < & str , str:: Utf8Error > {
28
- str:: from_utf8 ( & self . 0 )
29
- }
30
25
}
31
26
32
27
/// Predicate adaper that converts a `path` to file content predicate to byte predicate.
Original file line number Diff line number Diff line change 7
7
// except according to those terms.
8
8
9
9
use std:: fmt;
10
- use std:: io;
10
+ use std:: fs;
11
+ use std:: io:: { self , Read } ;
11
12
use std:: path;
13
+ use std:: str;
12
14
13
15
use Predicate ;
14
- use path:: fc:: FileContent ;
16
+
17
+ #[ derive( Clone , Debug , PartialEq ) ]
18
+ struct FileContent ( Vec < u8 > ) ;
19
+
20
+ impl FileContent {
21
+ pub fn new ( path : & path:: Path ) -> io:: Result < FileContent > {
22
+ let mut buffer = Vec :: new ( ) ;
23
+ fs:: File :: open ( path) ?. read_to_end ( & mut buffer) ?;
24
+ Ok ( FileContent ( buffer) )
25
+ }
26
+
27
+ pub fn utf8 ( & self ) -> Result < & str , str:: Utf8Error > {
28
+ str:: from_utf8 ( & self . 0 )
29
+ }
30
+ }
15
31
16
32
/// Predicate that compares file matches
17
33
#[ derive( Clone , Debug ) ]
You can’t perform that action at this time.
0 commit comments