Implement Deref<Target=Conn> for PooledConn
use std::collections::VecDeque;
use std::fmt;
+use std::ops::Deref;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::{Arc, Condvar, Mutex};
use std::time::Duration as StdDuration;
@@ -288,6 +289,14 @@ pub struct PooledConn {
conn: Option<Conn>,
}
+impl Deref for PooledConn {
+ type Target = Conn;
+
+ fn deref(&self) -> &Self::Target {
+ self.conn.as_ref().expect("deref after drop")
+ }
+}
+
impl Drop for PooledConn {
fn drop(&mut self) {
if self.pool.count.load(Ordering::Relaxed) > self.pool.max.load(Ordering::Relaxed)
