@@ -536,68 +536,35 @@ impl Cmd {
536
536
}
537
537
538
538
#[ doc( hidden) ]
539
- #[ derive( Default ) ]
539
+ #[ derive( Default , Debug ) ]
540
540
pub struct CmdString ( OsString ) ;
541
541
impl CmdString {
542
542
pub fn append < T : Any + fmt:: Debug > ( mut self , value : & T ) -> Self {
543
543
let value_any = value as & dyn Any ;
544
-
545
544
if let Some ( as_string) = value_any. downcast_ref :: < String > ( ) {
546
545
self . 0 . push ( as_string) ;
547
- return self ;
548
- }
549
-
550
- if let Some ( as_string) = value_any. downcast_ref :: < & String > ( ) {
546
+ } else if let Some ( as_string) = value_any. downcast_ref :: < & String > ( ) {
551
547
self . 0 . push ( as_string) ;
552
- return self ;
553
- }
554
-
555
- if let Some ( as_string) = value_any. downcast_ref :: < & str > ( ) {
548
+ } else if let Some ( as_string) = value_any. downcast_ref :: < & str > ( ) {
556
549
self . 0 . push ( as_string) ;
557
- return self ;
558
- }
559
-
560
- if let Some ( as_os_string) = value_any. downcast_ref :: < OsString > ( ) {
550
+ } else if let Some ( as_os_string) = value_any. downcast_ref :: < OsString > ( ) {
561
551
self . 0 . push ( as_os_string) ;
562
- return self ;
563
- }
564
-
565
- if let Some ( as_os_string) = value_any. downcast_ref :: < & OsString > ( ) {
552
+ } else if let Some ( as_os_string) = value_any. downcast_ref :: < & OsString > ( ) {
566
553
self . 0 . push ( as_os_string) ;
567
- return self ;
568
- }
569
-
570
- if let Some ( as_os_string) = value_any. downcast_ref :: < & OsStr > ( ) {
554
+ } else if let Some ( as_os_string) = value_any. downcast_ref :: < & OsStr > ( ) {
571
555
self . 0 . push ( as_os_string) ;
572
- return self ;
573
- }
574
-
575
- if let Some ( as_path_string) = value_any. downcast_ref :: < PathBuf > ( ) {
556
+ } else if let Some ( as_path_string) = value_any. downcast_ref :: < PathBuf > ( ) {
576
557
self . 0 . push ( as_path_string) ;
577
- return self ;
578
- }
579
-
580
- if let Some ( as_path_string) = value_any. downcast_ref :: < & PathBuf > ( ) {
558
+ } else if let Some ( as_path_string) = value_any. downcast_ref :: < & PathBuf > ( ) {
581
559
self . 0 . push ( as_path_string) ;
582
- return self ;
583
- }
584
-
585
- if let Some ( as_path_string) = value_any. downcast_ref :: < & Path > ( ) {
560
+ } else if let Some ( as_path_string) = value_any. downcast_ref :: < & Path > ( ) {
586
561
self . 0 . push ( as_path_string) ;
587
- return self ;
588
- }
589
-
590
- if let Some ( as_cmd_string) = value_any. downcast_ref :: < Self > ( ) {
591
- self . 0 . push ( & as_cmd_string. 0 ) ;
592
- return self ;
593
- }
594
-
595
- if let Some ( as_cmd_string) = value_any. downcast_ref :: < & Self > ( ) {
562
+ } else if let Some ( as_cmd_string) = value_any. downcast_ref :: < Self > ( ) {
596
563
self . 0 . push ( & as_cmd_string. 0 ) ;
597
- return self ;
564
+ } else {
565
+ self . 0 . push ( format ! ( "{:?}" , value) ) ;
598
566
}
599
567
600
- self . 0 . push ( format ! ( "{:?}" , value) ) ;
601
568
self
602
569
}
603
570
@@ -609,9 +576,9 @@ impl CmdString {
609
576
PathBuf :: from ( self . 0 )
610
577
}
611
578
}
612
- impl fmt:: Debug for CmdString {
579
+ impl fmt:: Display for CmdString {
613
580
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
614
- f. write_str ( & format ! ( "{:?}" , self . 0 ) )
581
+ f. write_str ( & self . 0 . to_str ( ) . unwrap ( ) . to_string ( ) )
615
582
}
616
583
}
617
584
0 commit comments