@@ -65,7 +65,6 @@ impl ExternArgs {
65
65
66
66
/// Run a `cargo build` to see what args Cargo is using for library paths and extern crates.
67
67
/// Touch a source file in the crate to ensure something is compiled and the args will be visible.
68
-
69
68
pub fn load ( & mut self , cargo_path : & Path ) -> Result < & Self > {
70
69
// find Cargo.toml and determine the package name and lib or bin source file.
71
70
let proj_root = cargo_path
@@ -77,7 +76,7 @@ impl ExternArgs {
77
76
. parent ( )
78
77
. ok_or ( anyhow ! ( "can't find parent of {:?}" , cargo_path) ) ?
79
78
. to_owned ( ) ;
80
- let mut manifest = Manifest :: from_path ( & cargo_path) . context ( format ! (
79
+ let mut manifest = Manifest :: from_path ( cargo_path) . context ( format ! (
81
80
"can't open cargo manifest {}" ,
82
81
& cargo_path. to_string_lossy( )
83
82
) ) ?;
@@ -107,7 +106,7 @@ impl ExternArgs {
107
106
let try_path: PathBuf = proj_root. join ( "src" ) . join ( fname) ;
108
107
if try_path. exists ( ) {
109
108
touch ( & try_path) ?;
110
- self . run_cargo ( & proj_root, & cargo_path) ?;
109
+ self . run_cargo ( & proj_root, cargo_path) ?;
111
110
return Ok ( self ) ;
112
111
// file should be closed when f goes out of scope at bottom of this loop
113
112
}
@@ -117,7 +116,7 @@ impl ExternArgs {
117
116
118
117
fn run_cargo ( & mut self , proj_root : & Path , manifest_path : & Path ) -> Result < & Self > {
119
118
let mut cmd = Command :: new ( "cargo" ) ;
120
- cmd. current_dir ( & proj_root)
119
+ cmd. current_dir ( proj_root)
121
120
. arg ( "build" )
122
121
. arg ( "--verbose" )
123
122
. arg ( "--manifest-path" )
@@ -138,7 +137,7 @@ impl ExternArgs {
138
137
//ultimatedebug std::fs::write(proj_root.join("mdbook_cargo_out.txt"), &output.stderr)?;
139
138
140
139
let cmd_resp: & str = std:: str:: from_utf8 ( & output. stderr ) ?;
141
- self . parse_response ( & self . crate_name . clone ( ) , & cmd_resp) ?;
140
+ self . parse_response ( self . crate_name . clone ( ) . as_str ( ) , cmd_resp) ?;
142
141
143
142
Ok ( self )
144
143
}
@@ -148,7 +147,7 @@ impl ExternArgs {
148
147
/// The response may contain multiple builds, scan for the one that corresponds to the doctest crate.
149
148
///
150
149
/// > This parser is broken, doesn't handle arg values with embedded spaces (single quoted).
151
- /// Fortunately, the args we care about (so far) don't have those kinds of values.
150
+ /// > Fortunately, the args we care about (so far) don't have those kinds of values.
152
151
pub fn parse_response ( & mut self , my_crate : & str , buf : & str ) -> Result < ( ) > {
153
152
let mut builds_ignored = 0 ;
154
153
@@ -200,7 +199,7 @@ impl ExternArgs {
200
199
} ;
201
200
}
202
201
203
- if self . extern_list . len ( ) == 0 || self . lib_list . len ( ) == 0 {
202
+ if self . extern_list . is_empty ( ) || self . lib_list . is_empty ( ) {
204
203
bail ! ( "Couldn't extract -L or --extern args from Cargo, is current directory == cargo project root?" ) ;
205
204
}
206
205
@@ -227,6 +226,12 @@ impl ExternArgs {
227
226
}
228
227
}
229
228
229
+ impl Default for ExternArgs {
230
+ fn default ( ) -> Self {
231
+ Self :: new ( )
232
+ }
233
+ }
234
+
230
235
fn my_display_edition ( edition : Edition ) -> String {
231
236
match edition {
232
237
Edition :: E2015 => "2015" ,
0 commit comments