rustup for clone trait

This commit is contained in:
Sean McArthur
2014-12-09 16:50:49 -08:00
parent 514f96e9eb
commit 89bedd30ba
3 changed files with 26 additions and 7 deletions

View File

@@ -42,13 +42,21 @@ pub trait NetworkAcceptor<S: NetworkStream>: Acceptor<S> + Clone + Send {
}
/// An abstraction over streams that a Server can utilize.
pub trait NetworkStream: Stream + Any + Clone + Send {
pub trait NetworkStream: Stream + Any + StreamClone + Send {
/// Get the remote address of the underlying connection.
fn peer_name(&mut self) -> IoResult<SocketAddr>;
}
#[doc(hidden)]
#[doc(hidden)]
pub trait StreamClone {
fn clone_box(&self) -> Box<NetworkStream + Send>;
}
impl<T: NetworkStream + Send + Clone> StreamClone for T {
#[inline]
fn clone_box(&self) -> Box<NetworkStream + Send> { box self.clone() }
fn clone_box(&self) -> Box<NetworkStream + Send> {
box self.clone()
}
}
/// A connector creates a NetworkStream.