diff --git a/tokio/src/io/async_fd.rs b/tokio/src/io/async_fd.rs index 65b02959571..6f698273451 100644 --- a/tokio/src/io/async_fd.rs +++ b/tokio/src/io/async_fd.rs @@ -559,7 +559,7 @@ impl AsyncFd { /// let async_fd = AsyncFd::new(socket)?; /// /// let written = async_fd - /// .async_io(Interest::WRITABLE, || async_fd.get_ref().send(&[1, 2])) + /// .async_io(Interest::WRITABLE, |inner| inner.send(&[1, 2])) /// .await?; /// /// println!("wrote {written} bytes"); @@ -596,9 +596,11 @@ impl AsyncFd { pub async fn async_io( &self, interest: Interest, - f: impl FnMut() -> io::Result, + mut f: impl FnMut(&T) -> io::Result, ) -> io::Result { - self.registration.async_io(interest, f).await + self.registration + .async_io(interest, || f(self.get_ref())) + .await } }