@@ -65,7 +65,6 @@ impl ExternArgs {
6565
6666 /// Run a `cargo build` to see what args Cargo is using for library paths and extern crates.
6767 /// Touch a source file in the crate to ensure something is compiled and the args will be visible.
68-
6968 pub fn load ( & mut self , cargo_path : & Path ) -> Result < & Self > {
7069 // find Cargo.toml and determine the package name and lib or bin source file.
7170 let proj_root = cargo_path
@@ -77,7 +76,7 @@ impl ExternArgs {
7776 . parent ( )
7877 . ok_or ( anyhow ! ( "can't find parent of {:?}" , cargo_path) ) ?
7978 . to_owned ( ) ;
80- let mut manifest = Manifest :: from_path ( & cargo_path) . context ( format ! (
79+ let mut manifest = Manifest :: from_path ( cargo_path) . context ( format ! (
8180 "can't open cargo manifest {}" ,
8281 & cargo_path. to_string_lossy( )
8382 ) ) ?;
@@ -107,7 +106,7 @@ impl ExternArgs {
107106 let try_path: PathBuf = proj_root. join ( "src" ) . join ( fname) ;
108107 if try_path. exists ( ) {
109108 touch ( & try_path) ?;
110- self . run_cargo ( & proj_root, & cargo_path) ?;
109+ self . run_cargo ( & proj_root, cargo_path) ?;
111110 return Ok ( self ) ;
112111 // file should be closed when f goes out of scope at bottom of this loop
113112 }
@@ -117,7 +116,7 @@ impl ExternArgs {
117116
118117 fn run_cargo ( & mut self , proj_root : & Path , manifest_path : & Path ) -> Result < & Self > {
119118 let mut cmd = Command :: new ( "cargo" ) ;
120- cmd. current_dir ( & proj_root)
119+ cmd. current_dir ( proj_root)
121120 . arg ( "build" )
122121 . arg ( "--verbose" )
123122 . arg ( "--manifest-path" )
@@ -138,7 +137,7 @@ impl ExternArgs {
138137 //ultimatedebug std::fs::write(proj_root.join("mdbook_cargo_out.txt"), &output.stderr)?;
139138
140139 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) ?;
142141
143142 Ok ( self )
144143 }
@@ -148,7 +147,7 @@ impl ExternArgs {
148147 /// The response may contain multiple builds, scan for the one that corresponds to the doctest crate.
149148 ///
150149 /// > 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.
152151 pub fn parse_response ( & mut self , my_crate : & str , buf : & str ) -> Result < ( ) > {
153152 let mut builds_ignored = 0 ;
154153
@@ -200,7 +199,7 @@ impl ExternArgs {
200199 } ;
201200 }
202201
203- if self . extern_list . len ( ) == 0 || self . lib_list . len ( ) == 0 {
202+ if self . extern_list . is_empty ( ) || self . lib_list . is_empty ( ) {
204203 bail ! ( "Couldn't extract -L or --extern args from Cargo, is current directory == cargo project root?" ) ;
205204 }
206205
@@ -227,6 +226,12 @@ impl ExternArgs {
227226 }
228227}
229228
229+ impl Default for ExternArgs {
230+ fn default ( ) -> Self {
231+ Self :: new ( )
232+ }
233+ }
234+
230235fn my_display_edition ( edition : Edition ) -> String {
231236 match edition {
232237 Edition :: E2015 => "2015" ,
0 commit comments