@@ -273,10 +273,7 @@ fn detect_source_paths_and_types(
273273 let pp = i. proposed_path ;
274274
275275 // path/pp does not exist or is not a file
276- if !fs:: metadata ( & path. join ( & pp) )
277- . map ( |x| x. is_file ( ) )
278- . unwrap_or ( false )
279- {
276+ if !path. join ( & pp) . is_file ( ) {
280277 continue ;
281278 }
282279
@@ -358,7 +355,7 @@ fn plan_new_source_file(bin: bool, package_name: String) -> SourceFileInformatio
358355
359356pub fn new ( opts : & NewOptions , config : & Config ) -> CargoResult < ( ) > {
360357 let path = & opts. path ;
361- if fs :: metadata ( path) . is_ok ( ) {
358+ if path. exists ( ) {
362359 anyhow:: bail!(
363360 "destination `{}` already exists\n \n \
364361 Use `cargo init` to initialize the directory",
@@ -397,7 +394,7 @@ pub fn init(opts: &NewOptions, config: &Config) -> CargoResult<()> {
397394
398395 let path = & opts. path ;
399396
400- if fs :: metadata ( & path. join ( "Cargo.toml" ) ) . is_ok ( ) {
397+ if path. join ( "Cargo.toml" ) . exists ( ) {
401398 anyhow:: bail!( "`cargo init` cannot be run on existing Cargo packages" )
402399 }
403400
@@ -428,22 +425,22 @@ pub fn init(opts: &NewOptions, config: &Config) -> CargoResult<()> {
428425 if version_control == None {
429426 let mut num_detected_vsces = 0 ;
430427
431- if fs :: metadata ( & path. join ( ".git" ) ) . is_ok ( ) {
428+ if path. join ( ".git" ) . exists ( ) {
432429 version_control = Some ( VersionControl :: Git ) ;
433430 num_detected_vsces += 1 ;
434431 }
435432
436- if fs :: metadata ( & path. join ( ".hg" ) ) . is_ok ( ) {
433+ if path. join ( ".hg" ) . exists ( ) {
437434 version_control = Some ( VersionControl :: Hg ) ;
438435 num_detected_vsces += 1 ;
439436 }
440437
441- if fs :: metadata ( & path. join ( ".pijul" ) ) . is_ok ( ) {
438+ if path. join ( ".pijul" ) . exists ( ) {
442439 version_control = Some ( VersionControl :: Pijul ) ;
443440 num_detected_vsces += 1 ;
444441 }
445442
446- if fs :: metadata ( & path. join ( ".fossil" ) ) . is_ok ( ) {
443+ if path. join ( ".fossil" ) . exists ( ) {
447444 version_control = Some ( VersionControl :: Fossil ) ;
448445 num_detected_vsces += 1 ;
449446 }
@@ -743,10 +740,7 @@ mod tests {
743740"
744741 } ;
745742
746- if !fs:: metadata ( & path_of_source_file)
747- . map ( |x| x. is_file ( ) )
748- . unwrap_or ( false )
749- {
743+ if !path_of_source_file. is_file ( ) {
750744 paths:: write ( & path_of_source_file, default_file_content) ?;
751745
752746 // Format the newly created source file
0 commit comments