Repository: sfackler/rust-postgres (rust)

Issue:
0.18: `Client` is no longer `Send`, therefor incompatible with r2d2
```
   |
8  |   type Connection = postgres::Client;
   |                     ^^^^^^^^^^^^^^^^ `(dyn std::ops::Fn(postgres::error::DbError) + 'static)` cannot be sent between threads safely
   | 
  ::: /home/charles/.cargo/registry/src/github.com-1ecc6299db9ec823/r2d2-0.8.9/src/lib.rs:72:22
   |
72 |     type Connection: Send + 'static;
   |                      ---- required by this bound in `r2d2::ManageConnection`
   |
   = help: the trait `std::marker::Send` is not implemented for `(dyn std::ops::Fn(postgres::error::DbError) + 'static)`
   = note: required because of the requirements on the impl of `std::marker::Send` for `std::sync::Arc<(dyn std::ops::Fn(postgres::error::DbError) + 'static)>`
   = note: required because it appears within the type `postgres::connection::Connection`
   = note: required because it appears within the type `postgres::Client`
```

Pull request:
Make postgres::Client Send again
Closes #677

Patch:
diff --git a/postgres/src/connection.rs b/postgres/src/connection.rs
index bc8564f5..453eef3a 100644
--- a/postgres/src/connection.rs
+++ b/postgres/src/connection.rs
@@ -16,14 +16,14 @@ pub struct Connection {
     runtime: Runtime,
     connection: Pin<Box<dyn Stream<Item = Result<AsyncMessage, Error>> + Send>>,
     notifications: VecDeque<Notification>,
-    notice_callback: Arc<dyn Fn(DbError)>,
+    notice_callback: Arc<dyn Fn(DbError) + Sync + Send>,
 }
 
 impl Connection {
     pub fn new<S, T>(
         runtime: Runtime,
         connection: tokio_postgres::Connection<S, T>,
-        notice_callback: Arc<dyn Fn(DbError)>,
+        notice_callback: Arc<dyn Fn(DbError) + Sync + Send>,
     ) -> Connection
     where
         S: AsyncRead + AsyncWrite + Unpin + 'static + Send,


Test patch:
diff --git a/postgres/src/test.rs b/postgres/src/test.rs
index dcf202ef..0fd40457 100644
--- a/postgres/src/test.rs
+++ b/postgres/src/test.rs
@@ -499,3 +499,12 @@ fn explicit_close() {
     let client = Client::connect("host=localhost port=5433 user=postgres", NoTls).unwrap();
     client.close().unwrap();
 }
+
+#[test]
+fn check_send() {
+    fn is_send<T: Send>() {}
+
+    is_send::<Client>();
+    is_send::<Statement>();
+    is_send::<Transaction<'_>>();
+}