File tree Expand file tree Collapse file tree 2 files changed +14
-32
lines changed Expand file tree Collapse file tree 2 files changed +14
-32
lines changed Original file line number Diff line number Diff line change @@ -2883,26 +2883,16 @@ pub struct Values {
28832883
28842884impl fmt:: Display for Values {
28852885 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
2886- struct DisplayRow < ' a > {
2887- exprs : & ' a [ Expr ] ,
2888- explicit_row : bool ,
2889- }
2890- impl fmt:: Display for DisplayRow < ' _ > {
2891- fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
2892- let comma_separated = display_comma_separated ( self . exprs ) ;
2893- if self . explicit_row {
2894- write ! ( f, "ROW({})" , comma_separated)
2895- } else {
2896- write ! ( f, "({})" , comma_separated)
2897- }
2898- }
2899- }
2900- let row_display_iter = self . rows . iter ( ) . map ( |row| DisplayRow {
2901- exprs : row,
2902- explicit_row : self . explicit_row ,
2903- } ) ;
29042886 f. write_str ( "VALUES" ) ?;
2905- indented_list ( f, row_display_iter) ?;
2887+ let prefix = if self . explicit_row { "ROW" } else { "" } ;
2888+ let mut separator = "" ;
2889+ for row in & self . rows {
2890+ f. write_str ( separator) ?;
2891+ separator = "," ;
2892+ SpaceOrNewline . fmt ( f) ?;
2893+ let comma_separated = display_comma_separated ( row) ;
2894+ Indent ( format_args ! ( "{prefix}({comma_separated})" ) ) . fmt ( f) ?;
2895+ }
29062896 Ok ( ( ) )
29072897 }
29082898}
Original file line number Diff line number Diff line change @@ -68,17 +68,12 @@ impl Display for SpaceOrNewline {
6868
6969/// A value that displays a comma-separated list of values.
7070/// When pretty-printed (using {:#}), it displays each value on a new line.
71- pub ( crate ) struct DisplayCommaSeparated < I , T : fmt:: Display > ( I )
72- where
73- I : IntoIterator < Item = T > + Clone ;
71+ pub ( crate ) struct DisplayCommaSeparated < ' a , T : fmt:: Display > ( & ' a [ T ] ) ;
7472
75- impl < I , T : fmt:: Display > fmt:: Display for DisplayCommaSeparated < I , T >
76- where
77- I : IntoIterator < Item = T > + Clone ,
78- {
73+ impl < T : fmt:: Display > fmt:: Display for DisplayCommaSeparated < ' _ , T > {
7974 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
8075 let mut first = true ;
81- for t in self . 0 . clone ( ) {
76+ for t in self . 0 {
8277 if !first {
8378 f. write_char ( ',' ) ?;
8479 SpaceOrNewline . fmt ( f) ?;
9186}
9287
9388/// Displays a whitespace, followed by a comma-separated list that is indented when pretty-printed.
94- pub ( crate ) fn indented_list < I , T : fmt:: Display > ( f : & mut fmt:: Formatter , iter : I ) -> fmt:: Result
95- where
96- I : IntoIterator < Item = T > + Clone ,
97- {
89+ pub ( crate ) fn indented_list < T : fmt:: Display > ( f : & mut fmt:: Formatter , items : & [ T ] ) -> fmt:: Result {
9890 SpaceOrNewline . fmt ( f) ?;
99- Indent ( DisplayCommaSeparated ( iter ) ) . fmt ( f)
91+ Indent ( DisplayCommaSeparated ( items ) ) . fmt ( f)
10092}
10193
10294#[ cfg( test) ]
You can’t perform that action at this time.
0 commit comments