File tree 3 files changed +7
-8
lines changed
3 files changed +7
-8
lines changed Original file line number Diff line number Diff line change @@ -45,7 +45,8 @@ fn main() {
45
45
It can also be used to parse the report file.
46
46
47
47
``` rust
48
- let records = LCOVParser :: from (" /path/to/report.lcov" ). parse (). unwrap ();
48
+ let parser = LCOVParser :: from_file (" /path/to/report.lcov" ). unwrap ();
49
+ let records = parser . parse (). unwrap ();
49
50
50
51
for record in records . iter () {
51
52
match record {
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ extern crate lcov_parser;
3
3
use lcov_parser:: { LCOVParser } ;
4
4
5
5
fn main ( ) {
6
- let parser = LCOVParser :: from ( "../../../fixture/report.lcov" ) ;
6
+ let parser = LCOVParser :: from_file ( "../../../fixture/report.lcov" ) . unwrap ( ) ;
7
7
let records = parser. parse ( ) . unwrap ( ) ;
8
8
9
9
for record in records. iter ( ) {
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ use combinator:: { record, report };
15
15
use std:: io:: { Read } ;
16
16
use std:: fs:: { File } ;
17
17
use std:: result:: { Result } ;
18
+ use std:: io:: { Result as IOResult } ;
18
19
use std:: path:: { Path } ;
19
20
use std:: convert:: { From } ;
20
21
use std:: fmt:: { Display , Formatter , Result as FormatResult } ;
@@ -54,14 +55,11 @@ impl LCOVParser {
54
55
let records = try!( parse_report ( value) ) ;
55
56
Ok ( records)
56
57
}
57
- }
58
-
59
- impl < P : AsRef < Path > > From < P > for LCOVParser {
60
- fn from ( path : P ) -> Self {
61
- let mut file = File :: open ( path) . unwrap ( ) ;
58
+ pub fn from_file < P : AsRef < Path > > ( path : P ) -> IOResult < Self > {
59
+ let mut file = try!( File :: open ( path) ) ;
62
60
let mut buffer = String :: new ( ) ;
63
61
let _ = file. read_to_string ( & mut buffer) ;
64
- LCOVParser :: new ( buffer. as_str ( ) )
62
+ Ok ( LCOVParser :: new ( buffer. as_str ( ) ) )
65
63
}
66
64
}
67
65
You can’t perform that action at this time.
0 commit comments