File tree Expand file tree Collapse file tree 2 files changed +7
-8
lines changed Expand file tree Collapse file tree 2 files changed +7
-8
lines changed Original file line number Diff line number Diff line change 1
1
#![ deny( rust_2018_idioms, unused_lifetimes) ]
2
2
3
+ use anyhow:: Result ;
3
4
use mdbook:: book:: { Book , Chapter } ;
4
5
use mdbook:: errors:: Error ;
5
6
use mdbook:: preprocess:: { CmdPreprocessor , Preprocessor , PreprocessorContext } ;
@@ -20,7 +21,8 @@ static ADMONITION_RE: Lazy<Regex> = Lazy::new(|| {
20
21
Regex :: new ( r"(?m)^ *> \[!(?<admon>[^]]+)\]\n(?<blockquote>(?: *>.*\n)+)" ) . unwrap ( )
21
22
} ) ;
22
23
23
- pub fn handle_preprocessing ( pre : & dyn Preprocessor ) -> Result < ( ) , Error > {
24
+ pub fn handle_preprocessing ( ) -> Result < ( ) , Error > {
25
+ let pre = Spec :: new ( ) ?;
24
26
let ( ctx, book) = CmdPreprocessor :: parse_input ( io:: stdin ( ) ) ?;
25
27
26
28
let book_version = Version :: parse ( & ctx. mdbook_version ) ?;
@@ -49,10 +51,9 @@ pub struct Spec {
49
51
}
50
52
51
53
impl Spec {
52
- pub fn new ( ) -> Spec {
53
- Spec {
54
- deny_warnings : std:: env:: var ( "SPEC_DENY_WARNINGS" ) . as_deref ( ) == Ok ( "1" ) ,
55
- }
54
+ fn new ( ) -> Result < Spec > {
55
+ let deny_warnings = std:: env:: var ( "SPEC_DENY_WARNINGS" ) . as_deref ( ) == Ok ( "1" ) ;
56
+ Ok ( Spec { deny_warnings } )
56
57
}
57
58
58
59
/// Generates link references to all rules on all pages, so you can easily
Original file line number Diff line number Diff line change @@ -12,9 +12,7 @@ fn main() {
12
12
None => { }
13
13
}
14
14
15
- let preprocessor = mdbook_spec:: Spec :: new ( ) ;
16
-
17
- if let Err ( e) = mdbook_spec:: handle_preprocessing ( & preprocessor) {
15
+ if let Err ( e) = mdbook_spec:: handle_preprocessing ( ) {
18
16
eprintln ! ( "{}" , e) ;
19
17
std:: process:: exit ( 1 ) ;
20
18
}
You can’t perform that action at this time.
0 commit comments