@@ -532,40 +532,43 @@ impl ValidationError {
532532 let mut parts = Vec :: new ( ) ;
533533
534534 if !self . duplicate_region_names . is_empty ( ) {
535- let names: Vec < & str > = self
536- . duplicate_region_names
537- . iter ( )
538- . map ( |n| n. as_str ( ) )
539- . collect ( ) ;
540- parts. push ( format ! ( "duplicate region names: {}" , names. join( ", " ) ) ) ;
535+ parts. push ( format ! (
536+ "duplicate region names: {}" ,
537+ format_name_list( & self . duplicate_region_names)
538+ ) ) ;
541539 }
542540
543541 if !self . duplicate_topology_names . is_empty ( ) {
544- let names: Vec < & str > = self
545- . duplicate_topology_names
546- . iter ( )
547- . map ( |n| n. as_str ( ) )
548- . collect ( ) ;
549- parts. push ( format ! ( "duplicate topology names: {}" , names. join( ", " ) ) ) ;
542+ parts. push ( format ! (
543+ "duplicate topology names: {}" ,
544+ format_name_list( & self . duplicate_topology_names)
545+ ) ) ;
550546 }
551547
552548 if !self . unknown_topology_regions . is_empty ( ) {
553- let names: Vec < & str > = self
554- . unknown_topology_regions
555- . iter ( )
556- . map ( |n| n. as_str ( ) )
557- . collect ( ) ;
558- parts. push ( format ! ( "unknown topology regions: {}" , names. join( ", " ) ) ) ;
549+ parts. push ( format ! (
550+ "unknown topology regions: {}" ,
551+ format_name_list( & self . unknown_topology_regions)
552+ ) ) ;
559553 }
560554
561555 if let Some ( ref name) = self . unknown_preferred_region {
562- parts. push ( format ! ( "unknown preferred region: {}" , name. as_str ( ) ) ) ;
556+ parts. push ( format ! ( "unknown preferred region: {}" , name) ) ;
563557 }
564558
565559 parts. join ( "; " )
566560 }
567561}
568562
563+ /// Formats a slice of displayable items as a comma-separated string.
564+ fn format_name_list < T : std:: fmt:: Display > ( names : & [ T ] ) -> String {
565+ names
566+ . iter ( )
567+ . map ( |n| n. to_string ( ) )
568+ . collect :: < Vec < _ > > ( )
569+ . join ( ", " )
570+ }
571+
569572impl < T : Clone + Debug + Eq + PartialEq + Serialize + for < ' a > Deserialize < ' a > >
570573 MultiCloudMultiRegionConfiguration < T >
571574{
0 commit comments