Skip to content

Commit 2b1949d

Browse files
committed
impl Debug for Statement
The lack of this common trait bound caused some unpleasantness. For example, the following didn't compile: let x = OnceLock::new(); let stmt = db.prepare(...)?; x.set(stmt).expect(...); // returns Result<(), T=Statement> where T: Debug
1 parent 98f5a11 commit 2b1949d

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

tokio-postgres/src/statement.rs

+10
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,16 @@ impl Statement {
6161
}
6262
}
6363

64+
impl std::fmt::Debug for Statement {
65+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
66+
f.debug_struct("Statement")
67+
.field("name", &self.0.name)
68+
.field("params", &self.0.params)
69+
.field("columns", &self.0.columns)
70+
.finish_non_exhaustive()
71+
}
72+
}
73+
6474
/// Information about a column of a query.
6575
#[derive(Debug)]
6676
pub struct Column {

0 commit comments

Comments
 (0)