Make Incoming take self mutably
@@ -144,7 +144,7 @@ impl TcpListener {
/// }
/// # Ok(())}
/// ```
- pub fn incoming(&self) -> Incoming<'_> {
+ pub fn incoming(&mut self) -> Incoming<'_> {
Incoming { inner: self }
}
@@ -194,7 +194,7 @@ impl TcpListener {
self.io.get_ref().set_ttl(ttl)
}
- fn poll_accept(&self, lw: &LocalWaker) -> Poll<io::Result<(TcpStream, SocketAddr)>> {
+ fn poll_accept(&mut self, lw: &LocalWaker) -> Poll<io::Result<(TcpStream, SocketAddr)>> {
let (io, addr) = ready!(self.poll_accept_std(lw)?);
let io = mio::net::TcpStream::from_stream(io)?;
@@ -204,7 +204,7 @@ impl TcpListener {
}
fn poll_accept_std(
- &self,
+ &mut self,
lw: &LocalWaker,
) -> Poll<io::Result<(net::TcpStream, SocketAddr)>> {
ready!(self.io.poll_read_ready(lw)?);
@@ -243,13 +243,13 @@ mod sys {
#[must_use = "streams do nothing unless polled"]
#[derive(Debug)]
pub struct Incoming<'a> {
- inner: &'a TcpListener,
+ inner: &'a mut TcpListener,
}
impl<'a> Stream for Incoming<'a> {
type Item = io::Result<TcpStream>;
- fn poll_next(self: Pin<&mut Self>, lw: &LocalWaker) -> Poll<Option<Self::Item>> {
+ fn poll_next(mut self: Pin<&mut Self>, lw: &LocalWaker) -> Poll<Option<Self::Item>> {
let (socket, _) = ready!(self.inner.poll_accept(lw)?);
Poll::Ready(Some(Ok(socket)))
}
