Skip to content

Commit 8735d40

Browse files
taiki-eNemo157
authored andcommitted
impl AsyncRead for Pin<&'a mut T>
1 parent d43f417 commit 8735d40

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

futures-io/src/lib.rs

+18
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,24 @@ mod if_std {
270270
deref_async_read!();
271271
}
272272

273+
impl<'a, T: ?Sized + AsyncRead> AsyncRead for Pin<&'a mut T> {
274+
unsafe fn initializer(&self) -> Initializer {
275+
(**self).initializer()
276+
}
277+
278+
fn poll_read(mut self: Pin<&mut Self>, waker: &Waker, buf: &mut [u8])
279+
-> Poll<Result<usize>>
280+
{
281+
T::poll_read((*self).as_mut(), waker, buf)
282+
}
283+
284+
fn poll_vectored_read(mut self: Pin<&mut Self>, waker: &Waker, vec: &mut [&mut IoVec])
285+
-> Poll<Result<usize>>
286+
{
287+
T::poll_vectored_read((*self).as_mut(), waker, vec)
288+
}
289+
}
290+
273291
/// `unsafe` because the `StdIo::Read` type must not access the buffer
274292
/// before reading data into it.
275293
macro_rules! unsafe_delegate_async_read_to_stdio {

0 commit comments

Comments
 (0)