@@ -100,59 +100,10 @@ pub struct Row {
100
100
ranges : Vec < Option < Range < usize > > > ,
101
101
}
102
102
103
- /// A macro to map pg types to rust types, for debug display.
104
- macro_rules! debug_row_type {
105
- ( $this: expr; $map: expr; $idx: expr; $name: expr; $type: expr; $( $pg_ty: tt => $ty: ty) ,* ) => {
106
- match $type {
107
- $(
108
- & Type :: $pg_ty => match <$ty as FromSql >:: from_sql_nullable(
109
- & Type :: $pg_ty,
110
- $this. 0 . col_buffer( $idx) ,
111
- ) {
112
- Ok ( val) => $map. entry( & $name, & val) ,
113
- Err ( _) => $map. entry( & $name, & "<error>" ) ,
114
- } ,
115
- ) *
116
- _ => $map. entry( & $name, & "<opaque type>" ) ,
117
- }
118
- }
119
- }
120
-
121
103
impl fmt:: Debug for Row {
122
104
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
123
- // Provides debug impl for row contents.
124
- struct RowData < ' a > ( & ' a Row ) ;
125
-
126
- impl fmt:: Debug for RowData < ' _ > {
127
- #[ allow( clippy:: match_ref_pats) ]
128
- fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
129
- let mut map = f. debug_map ( ) ;
130
- for ( idx, col) in self . 0 . columns ( ) . iter ( ) . enumerate ( ) {
131
- debug_row_type ! ( self ; map; idx; col. name( ) ; col. type_( ) ;
132
- BOOL => bool ,
133
- INT2 => i16 ,
134
- INT4 => i32 ,
135
- INT8 => i64 ,
136
- FLOAT4 => f32 ,
137
- FLOAT8 => f64 ,
138
- VARCHAR => String ,
139
- BPCHAR => String ,
140
- TEXT => String ,
141
- JSON => String ,
142
- XML => String ,
143
- TIMESTAMPTZ => std:: time:: SystemTime ,
144
- TIMESTAMP => std:: time:: SystemTime ,
145
- BYTEA => Vec <u8 >
146
- // More types could be added here.
147
- ) ;
148
- }
149
- map. finish ( )
150
- }
151
- }
152
-
153
105
f. debug_struct ( "Row" )
154
106
. field ( "columns" , & self . columns ( ) )
155
- . field ( "data" , & RowData ( self ) )
156
107
. finish ( )
157
108
}
158
109
}
0 commit comments