diff --git a/src/lib.rs b/src/lib.rs index 36a688f5..c2b98fc7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -218,11 +218,19 @@ impl IntoConnectParams for Url { } /// Trait for types that can handle Postgres notice messages +/// +/// It is implemented for all `Send + FnMut(DbError)` closures. pub trait HandleNotice: Send { /// Handle a Postgres notice message fn handle_notice(&mut self, notice: DbError); } +impl HandleNotice for F { + fn handle_notice(&mut self, notice: DbError) { + self(notice) + } +} + /// A notice handler which logs at the `info` level. /// /// This is the default handler used by a `Connection`.