sfackler / rust-postgres

Native PostgreSQL driver for the Rust programming language
Apache License 2.0
3.39k stars 429 forks source link

impl Debug for Statement #1153

Closed cammeresi closed 1 week ago

cammeresi commented 1 week ago

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

sfackler commented 1 week ago

LGTM, but the specific example in the PR description would probably be more cleanly implemented as x.set(stmt).ok().expect(...) since the debug representation of the second statement is probably not going to provide any extra clarity.