@@ -318,7 +318,7 @@ pub fn new(opts: &NewOptions, config: &Config) -> CargoResult<()> {
318318
319319 let mkopts = MkOptions {
320320 version_control : opts. version_control ,
321- path : & path ,
321+ path,
322322 name,
323323 source_files : vec ! [ plan_new_source_file( opts. kind. is_bin( ) , name. to_string( ) ) ] ,
324324 bin : opts. kind . is_bin ( ) ,
@@ -341,12 +341,12 @@ pub fn init(opts: &NewOptions, config: &Config) -> CargoResult<()> {
341341 bail ! ( "`cargo init` cannot be run on existing Cargo projects" )
342342 }
343343
344- let name = get_name ( & path, opts) ?;
344+ let name = get_name ( path, opts) ?;
345345 check_name ( name, opts) ?;
346346
347347 let mut src_paths_types = vec ! [ ] ;
348348
349- detect_source_paths_and_types ( & path, name, & mut src_paths_types) ?;
349+ detect_source_paths_and_types ( path, name, & mut src_paths_types) ?;
350350
351351 if src_paths_types. is_empty ( ) {
352352 src_paths_types. push ( plan_new_source_file ( opts. kind . is_bin ( ) , name. to_string ( ) ) ) ;
@@ -444,37 +444,40 @@ fn mk(config: &Config, opts: &MkOptions) -> CargoResult<()> {
444444
445445 match vcs {
446446 VersionControl :: Git => {
447- if !fs :: metadata ( & path. join ( ".git" ) ) . is_ok ( ) {
447+ if !path. join ( ".git" ) . exists ( ) {
448448 GitRepo :: init ( path, config. cwd ( ) ) ?;
449449 }
450- let ignore = match fs:: metadata ( & path. join ( ".gitignore" ) ) {
451- Ok ( _) => format ! ( "\n {}" , ignore) ,
452- _ => ignore,
450+ let ignore = if path. join ( ".gitignore" ) . exists ( ) {
451+ format ! ( "\n {}" , ignore)
452+ } else {
453+ ignore
453454 } ;
454455 paths:: append ( & path. join ( ".gitignore" ) , ignore. as_bytes ( ) ) ?;
455456 }
456457 VersionControl :: Hg => {
457- if !fs :: metadata ( & path. join ( ".hg" ) ) . is_ok ( ) {
458+ if !path. join ( ".hg" ) . exists ( ) {
458459 HgRepo :: init ( path, config. cwd ( ) ) ?;
459460 }
460- let hgignore = match fs:: metadata ( & path. join ( ".hgignore" ) ) {
461- Ok ( _) => format ! ( "\n {}" , hgignore) ,
462- _ => hgignore,
461+ let hgignore = if path. join ( ".hgignore" ) . exists ( ) {
462+ format ! ( "\n {}" , hgignore)
463+ } else {
464+ hgignore
463465 } ;
464466 paths:: append ( & path. join ( ".hgignore" ) , hgignore. as_bytes ( ) ) ?;
465467 }
466468 VersionControl :: Pijul => {
467- if !fs :: metadata ( & path. join ( ".pijul" ) ) . is_ok ( ) {
469+ if !path. join ( ".pijul" ) . exists ( ) {
468470 PijulRepo :: init ( path, config. cwd ( ) ) ?;
469471 }
470- let ignore = match fs:: metadata ( & path. join ( ".ignore" ) ) {
471- Ok ( _) => format ! ( "\n {}" , ignore) ,
472- _ => ignore,
472+ let ignore = if path. join ( ".ignore" ) . exists ( ) {
473+ format ! ( "\n {}" , ignore)
474+ } else {
475+ ignore
473476 } ;
474477 paths:: append ( & path. join ( ".ignore" ) , ignore. as_bytes ( ) ) ?;
475478 }
476479 VersionControl :: Fossil => {
477- if !fs :: metadata ( & path. join ( ".fossil" ) ) . is_ok ( ) {
480+ if path. join ( ".fossil" ) . exists ( ) {
478481 FossilRepo :: init ( path, config. cwd ( ) ) ?;
479482 }
480483 }
0 commit comments