File tree Expand file tree Collapse file tree 2 files changed +13
-32
lines changed Expand file tree Collapse file tree 2 files changed +13
-32
lines changed Original file line number Diff line number Diff line change @@ -2883,26 +2883,15 @@ pub struct Values {
2883
2883
2884
2884
impl fmt:: Display for Values {
2885
2885
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
- } ) ;
2904
2886
f. write_str ( "VALUES" ) ?;
2905
- indented_list ( f, row_display_iter) ?;
2887
+ let prefix = if self . explicit_row { "ROW" } else { "" } ;
2888
+ let mut delim = "" ;
2889
+ for row in & self . rows {
2890
+ f. write_str ( delim) ?;
2891
+ delim = "," ;
2892
+ SpaceOrNewline . fmt ( f) ?;
2893
+ Indent ( format_args ! ( "{prefix}({})" , display_comma_separated( row) ) ) . fmt ( f) ?;
2894
+ }
2906
2895
Ok ( ( ) )
2907
2896
}
2908
2897
}
Original file line number Diff line number Diff line change @@ -68,17 +68,12 @@ impl Display for SpaceOrNewline {
68
68
69
69
/// A value that displays a comma-separated list of values.
70
70
/// 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 ] ) ;
74
72
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 > {
79
74
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
80
75
let mut first = true ;
81
- for t in self . 0 . clone ( ) {
76
+ for t in self . 0 {
82
77
if !first {
83
78
f. write_char ( ',' ) ?;
84
79
SpaceOrNewline . fmt ( f) ?;
91
86
}
92
87
93
88
/// 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 {
98
90
SpaceOrNewline . fmt ( f) ?;
99
- Indent ( DisplayCommaSeparated ( iter ) ) . fmt ( f)
91
+ Indent ( DisplayCommaSeparated ( items ) ) . fmt ( f)
100
92
}
101
93
102
94
#[ cfg( test) ]
You can’t perform that action at this time.
0 commit comments