|
43 | 43 | //! } |
44 | 44 | //! ``` |
45 | 45 | #![doc(html_root_url="https://sfackler.github.io/rust-postgres/doc")] |
46 | | -#![feature(unsafe_destructor, collections, io, core, net)] |
| 46 | +#![feature(unsafe_destructor, collections, io, core, net, debug_builders)] |
47 | 47 | #![cfg_attr(feature = "unix_socket", feature(path))] |
48 | 48 | #![warn(missing_docs)] |
49 | 49 | #![no_implicit_prelude] |
@@ -259,7 +259,9 @@ pub struct Notifications<'conn> { |
259 | 259 |
|
260 | 260 | impl<'a> fmt::Debug for Notifications<'a> { |
261 | 261 | fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { |
262 | | - write!(fmt, "Notifications {{ pending: {} }}", self.conn.conn.borrow().notifications.len()) |
| 262 | + fmt.debug_struct("Notifications") |
| 263 | + .field("pending", &self.conn.conn.borrow().notifications.len()) |
| 264 | + .finish() |
263 | 265 | } |
264 | 266 | } |
265 | 267 |
|
@@ -882,14 +884,13 @@ pub struct Connection { |
882 | 884 | impl fmt::Debug for Connection { |
883 | 885 | fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { |
884 | 886 | let conn = self.conn.borrow(); |
885 | | - write!(fmt, |
886 | | - "Connection {{ cancel_data: {:?}, notifications: {:?}, transaction_depth: {:?}, \ |
887 | | - desynchronized: {:?}, cached_statements: {:?} }}", |
888 | | - conn.cancel_data, |
889 | | - conn.notifications.len(), |
890 | | - conn.trans_depth, |
891 | | - conn.desynchronized, |
892 | | - conn.cached_statements.len()) |
| 887 | + fmt.debug_struct("Connection") |
| 888 | + .field("cancel_data", &conn.cancel_data) |
| 889 | + .field("notifications", &conn.notifications.len()) |
| 890 | + .field("transaction_depth", &conn.trans_depth) |
| 891 | + .field("desynchronized", &conn.desynchronized) |
| 892 | + .field("cached_statements", &conn.cached_statements.len()) |
| 893 | + .finish() |
893 | 894 | } |
894 | 895 | } |
895 | 896 |
|
@@ -1196,7 +1197,10 @@ pub struct Transaction<'conn> { |
1196 | 1197 |
|
1197 | 1198 | impl<'a> fmt::Debug for Transaction<'a> { |
1198 | 1199 | fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { |
1199 | | - write!(fmt, "Transaction {{ commit: {:?}, depth: {:?} }}", self.commit.get(), self.depth) |
| 1200 | + fmt.debug_struct("Transaction") |
| 1201 | + .field("commit", &self.commit.get()) |
| 1202 | + .field("depth", &self.depth) |
| 1203 | + .finish() |
1200 | 1204 | } |
1201 | 1205 | } |
1202 | 1206 |
|
@@ -1324,11 +1328,11 @@ pub struct Statement<'conn> { |
1324 | 1328 |
|
1325 | 1329 | impl<'a> fmt::Debug for Statement<'a> { |
1326 | 1330 | fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { |
1327 | | - write!(fmt, |
1328 | | - "Statement {{ name: {:?}, parameter_types: {:?}, columns: {:?} }}", |
1329 | | - self.name, |
1330 | | - self.param_types, |
1331 | | - self.columns) |
| 1331 | + fmt.debug_struct("Statement") |
| 1332 | + .field("name", &self.name) |
| 1333 | + .field("parameter_types", &self.param_types) |
| 1334 | + .field("columns", &self.columns) |
| 1335 | + .finish() |
1332 | 1336 | } |
1333 | 1337 | } |
1334 | 1338 |
|
@@ -1628,7 +1632,10 @@ pub struct Rows<'stmt> { |
1628 | 1632 |
|
1629 | 1633 | impl<'a> fmt::Debug for Rows<'a> { |
1630 | 1634 | fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { |
1631 | | - write!(fmt, "Rows {{ columns: {:?}, rows: {:?} }}", self.columns(), self.data.len()) |
| 1635 | + fmt.debug_struct("Rows") |
| 1636 | + .field("columns", &self.columns()) |
| 1637 | + .field("rows", &self.data.len()) |
| 1638 | + .finish() |
1632 | 1639 | } |
1633 | 1640 | } |
1634 | 1641 |
|
@@ -1768,7 +1775,9 @@ pub struct Row<'a> { |
1768 | 1775 |
|
1769 | 1776 | impl<'a> fmt::Debug for Row<'a> { |
1770 | 1777 | fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { |
1771 | | - write!(fmt, "Row {{ statement: {:?} }}", self.stmt) |
| 1778 | + fmt.debug_struct("Row") |
| 1779 | + .field("statement", self.stmt) |
| 1780 | + .finish() |
1772 | 1781 | } |
1773 | 1782 | } |
1774 | 1783 |
|
@@ -1887,13 +1896,12 @@ impl<'a, 'b> Drop for LazyRows<'a, 'b> { |
1887 | 1896 |
|
1888 | 1897 | impl<'a, 'b> fmt::Debug for LazyRows<'a, 'b> { |
1889 | 1898 | fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { |
1890 | | - write!(fmt, |
1891 | | - "LazyRows {{ name: {:?}, row_limit: {:?}, remaining_rows: {:?}, \ |
1892 | | - more_rows: {:?} }}", |
1893 | | - self.name, |
1894 | | - self.row_limit, |
1895 | | - self.data.len(), |
1896 | | - self.more_rows) |
| 1899 | + fmt.debug_struct("LazyRows") |
| 1900 | + .field("name", &self.name) |
| 1901 | + .field("row_limit", &self.row_limit) |
| 1902 | + .field("remaining_rows", &self.data.len()) |
| 1903 | + .field("more_rows", &self.more_rows) |
| 1904 | + .finish() |
1897 | 1905 | } |
1898 | 1906 | } |
1899 | 1907 |
|
@@ -1969,8 +1977,10 @@ pub struct CopyInStatement<'a> { |
1969 | 1977 |
|
1970 | 1978 | impl<'a> fmt::Debug for CopyInStatement<'a> { |
1971 | 1979 | fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { |
1972 | | - write!(fmt, "CopyInStatement {{ name: {:?}, column_types: {:?} }}", |
1973 | | - self.name, self.column_types) |
| 1980 | + fmt.debug_struct("CopyInStatement") |
| 1981 | + .field("name", &self.name) |
| 1982 | + .field("column_types", &self.column_types) |
| 1983 | + .finish() |
1974 | 1984 | } |
1975 | 1985 | } |
1976 | 1986 |
|
|
0 commit comments