@@ -524,7 +524,7 @@ fn print_lockfile_generation(
524
524
assert_eq ! ( change. kind, PackageChangeKind :: Added ) ;
525
525
ws. gctx ( ) . shell ( ) . status_with_color (
526
526
change. kind . status ( ) ,
527
- format ! ( "{package_id }{note}" ) ,
527
+ format ! ( "{change }{note}" ) ,
528
528
& change. kind . style ( ) ,
529
529
) ?;
530
530
}
@@ -562,19 +562,12 @@ fn print_lockfile_sync(
562
562
} ;
563
563
564
564
let package_id = change. package_id ;
565
- if let Some ( previous_id ) = change. previous_id {
565
+ if change. previous_id . is_some ( ) {
566
566
let required_rust_version = report_required_rust_version ( ws, resolve, package_id) ;
567
567
let latest = report_latest ( & possibilities, package_id) ;
568
568
let note = required_rust_version. or ( latest) . unwrap_or_default ( ) ;
569
569
570
- let msg = if package_id. source_id ( ) . is_git ( ) {
571
- format ! (
572
- "{previous_id} -> #{}{note}" ,
573
- & package_id. source_id( ) . precise_git_fragment( ) . unwrap( ) [ ..8 ] ,
574
- )
575
- } else {
576
- format ! ( "{previous_id} -> v{}{note}" , package_id. version( ) )
577
- } ;
570
+ let msg = format ! ( "{change}{note}" ) ;
578
571
579
572
if change. kind == PackageChangeKind :: Downgraded {
580
573
ws. gctx ( ) . shell ( ) . status_with_color (
@@ -597,7 +590,7 @@ fn print_lockfile_sync(
597
590
598
591
ws. gctx ( ) . shell ( ) . status_with_color (
599
592
change. kind . status ( ) ,
600
- format ! ( "{package_id }{note}" ) ,
593
+ format ! ( "{change }{note}" ) ,
601
594
& change. kind . style ( ) ,
602
595
) ?;
603
596
}
@@ -636,19 +629,12 @@ fn print_lockfile_updates(
636
629
} ;
637
630
638
631
let package_id = change. package_id ;
639
- if let Some ( previous_id ) = change. previous_id {
632
+ if change. previous_id . is_some ( ) {
640
633
let required_rust_version = report_required_rust_version ( ws, resolve, package_id) ;
641
634
let latest = report_latest ( & possibilities, package_id) ;
642
635
let note = required_rust_version. or ( latest) . unwrap_or_default ( ) ;
643
636
644
- let msg = if package_id. source_id ( ) . is_git ( ) {
645
- format ! (
646
- "{previous_id} -> #{}{note}" ,
647
- & package_id. source_id( ) . precise_git_fragment( ) . unwrap( ) [ ..8 ] ,
648
- )
649
- } else {
650
- format ! ( "{previous_id} -> v{}{note}" , package_id. version( ) )
651
- } ;
637
+ let msg = format ! ( "{change}{note}" ) ;
652
638
653
639
if change. kind == PackageChangeKind :: Downgraded {
654
640
ws. gctx ( ) . shell ( ) . status_with_color (
@@ -667,7 +653,7 @@ fn print_lockfile_updates(
667
653
if change. kind == PackageChangeKind :: Removed {
668
654
ws. gctx ( ) . shell ( ) . status_with_color (
669
655
change. kind . status ( ) ,
670
- format ! ( "{package_id }" ) ,
656
+ format ! ( "{change }" ) ,
671
657
& change. kind . style ( ) ,
672
658
) ?;
673
659
} else if change. kind == PackageChangeKind :: Added {
@@ -677,7 +663,7 @@ fn print_lockfile_updates(
677
663
678
664
ws. gctx ( ) . shell ( ) . status_with_color (
679
665
change. kind . status ( ) ,
680
- format ! ( "{package_id }{note}" ) ,
666
+ format ! ( "{change }{note}" ) ,
681
667
& change. kind . style ( ) ,
682
668
) ?;
683
669
}
@@ -694,7 +680,7 @@ fn print_lockfile_updates(
694
680
if ws. gctx ( ) . shell ( ) . verbosity ( ) == Verbosity :: Verbose {
695
681
ws. gctx ( ) . shell ( ) . status_with_color (
696
682
change. kind . status ( ) ,
697
- format ! ( "{package_id }{note}" ) ,
683
+ format ! ( "{change }{note}" ) ,
698
684
& change. kind . style ( ) ,
699
685
) ?;
700
686
}
@@ -911,6 +897,25 @@ impl PackageChange {
911
897
}
912
898
}
913
899
900
+ impl std:: fmt:: Display for PackageChange {
901
+ fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
902
+ let package_id = self . package_id ;
903
+ if let Some ( previous_id) = self . previous_id {
904
+ if package_id. source_id ( ) . is_git ( ) {
905
+ write ! (
906
+ f,
907
+ "{previous_id} -> #{}" ,
908
+ & package_id. source_id( ) . precise_git_fragment( ) . unwrap( ) [ ..8 ] ,
909
+ )
910
+ } else {
911
+ write ! ( f, "{previous_id} -> v{}" , package_id. version( ) )
912
+ }
913
+ } else {
914
+ write ! ( f, "{package_id}" )
915
+ }
916
+ }
917
+ }
918
+
914
919
#[ derive( Copy , Clone , Debug , PartialEq , Eq , PartialOrd , Ord , Hash ) ]
915
920
enum PackageChangeKind {
916
921
Added ,
0 commit comments