From 6fd69dfd474d378ecdeecc77b1e9ec1acbb9a749 Mon Sep 17 00:00:00 2001 From: Richard Dodd Date: Tue, 21 Jan 2020 17:21:05 +0000 Subject: [PATCH] Make requested changes --- tokio-postgres/src/row.rs | 49 --------------------------------------- 1 file changed, 49 deletions(-) diff --git a/tokio-postgres/src/row.rs b/tokio-postgres/src/row.rs index 05a5117e..842216ad 100644 --- a/tokio-postgres/src/row.rs +++ b/tokio-postgres/src/row.rs @@ -100,59 +100,10 @@ pub struct Row { ranges: Vec>>, } -/// A macro to map pg types to rust types, for debug display. -macro_rules! debug_row_type { - ($this:expr; $map:expr; $idx:expr; $name:expr; $type:expr; $($pg_ty:tt => $ty:ty),*) => { - match $type { - $( - &Type::$pg_ty => match <$ty as FromSql>::from_sql_nullable( - &Type::$pg_ty, - $this.0.col_buffer($idx), - ) { - Ok(val) => $map.entry(&$name, &val), - Err(_) => $map.entry(&$name, &""), - }, - )* - _ => $map.entry(&$name, &""), - } - } -} - impl fmt::Debug for Row { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - // Provides debug impl for row contents. - struct RowData<'a>(&'a Row); - - impl fmt::Debug for RowData<'_> { - #[allow(clippy::match_ref_pats)] - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let mut map = f.debug_map(); - for (idx, col) in self.0.columns().iter().enumerate() { - debug_row_type!(self; map; idx; col.name(); col.type_(); - BOOL => bool, - INT2 => i16, - INT4 => i32, - INT8 => i64, - FLOAT4 => f32, - FLOAT8 => f64, - VARCHAR => String, - BPCHAR => String, - TEXT => String, - JSON => String, - XML => String, - TIMESTAMPTZ => std::time::SystemTime, - TIMESTAMP => std::time::SystemTime, - BYTEA => Vec - // More types could be added here. - ); - } - map.finish() - } - } - f.debug_struct("Row") .field("columns", &self.columns()) - .field("data", &RowData(self)) .finish() } }