From c393236dfd12c13e82badd631d3a3a90481c6f95 Mon Sep 17 00:00:00 2001 From: Sean McArthur Date: Thu, 13 Aug 2020 20:15:01 -0700 Subject: io: change AsyncRead to use a ReadBuf (#2758) Works towards #2716. Changes the argument to `AsyncRead::poll_read` to take a `ReadBuf` struct that safely manages writes to uninitialized memory. --- tokio/tests/io_split.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'tokio/tests/io_split.rs') diff --git a/tokio/tests/io_split.rs b/tokio/tests/io_split.rs index e54bf248..7b401424 100644 --- a/tokio/tests/io_split.rs +++ b/tokio/tests/io_split.rs @@ -1,7 +1,7 @@ #![warn(rust_2018_idioms)] #![cfg(feature = "full")] -use tokio::io::{split, AsyncRead, AsyncWrite, ReadHalf, WriteHalf}; +use tokio::io::{split, AsyncRead, AsyncWrite, ReadBuf, ReadHalf, WriteHalf}; use std::io; use std::pin::Pin; @@ -13,9 +13,10 @@ impl AsyncRead for RW { fn poll_read( self: Pin<&mut Self>, _cx: &mut Context<'_>, - _buf: &mut [u8], - ) -> Poll> { - Poll::Ready(Ok(1)) + buf: &mut ReadBuf<'_>, + ) -> Poll> { + buf.append(&[b'z']); + Poll::Ready(Ok(())) } } -- cgit v1.2.3