(&mut self)
| 341 | |
| 342 | impl Drop for PooledConnection { |
| 343 | fn drop(&mut self) { |
| 344 | if let Some(conn) = self.conn.take() { |
| 345 | let mut conns = self.pool.lock().unwrap(); |
| 346 | let mut stats = self.stats.lock().unwrap(); |
| 347 | |
| 348 | // Return connection to pool wrapped in PoolConnection |
| 349 | conns.push(PoolConnection::new(conn)); |
| 350 | stats.idle_connections += 1; |
| 351 | stats.active_connections = stats.active_connections.saturating_sub(1); |
| 352 | } |
| 353 | } |
| 354 | } |
| 355 | |
| 356 | #[cfg(test)] |