Skip to content

Commit

Permalink
fix(client): Manually impl Debug for PooledStream
Browse files Browse the repository at this point in the history
Mutex's impl has a 'static bound on the inner type until 1.8, so we have
to explicitly specify that to keep compatible.
  • Loading branch information
sfackler committed May 20, 2016
1 parent 053eeeb commit aa69223
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/client/pool.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Client Connection Pooling
use std::borrow::ToOwned;
use std::collections::HashMap;
use std::fmt;
use std::io::{self, Read, Write};
use std::net::{SocketAddr, Shutdown};
use std::sync::{Arc, Mutex};
Expand Down Expand Up @@ -136,13 +137,23 @@ impl<C: NetworkConnector<Stream=S>, S: NetworkStream + Send> NetworkConnector fo
}

/// A Stream that will try to be returned to the Pool when dropped.
#[derive(Debug)]
pub struct PooledStream<S> {
inner: Option<PooledStreamInner<S>>,
is_closed: bool,
pool: Arc<Mutex<PoolImpl<S>>>,
}

// manual impl to add the 'static bound for 1.7 compat
impl<S> fmt::Debug for PooledStream<S> where S: fmt::Debug + 'static {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
fmt.debug_struct("PooledStream")
.field("inner", &self.inner)
.field("is_closed", &self.is_closed)
.field("pool", &self.pool)
.finish()
}
}

impl<S: NetworkStream> PooledStream<S> {
/// Take the wrapped stream out of the pool completely.
pub fn into_inner(mut self) -> S {
Expand Down

0 comments on commit aa69223

Please sign in to comment.