diff options
author | Carl Lerche <me@carllerche.com> | 2019-11-20 14:27:49 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-20 14:27:49 -0800 |
commit | 5cd665afd7b70b184b559e6407fdf645983e1314 (patch) | |
tree | 2197d4502d01218ca6df8c076f55d83027a18230 /tokio/tests/io_async_read.rs | |
parent | 3e643c7b81736a4c2b11387a6f71aba99450270b (diff) |
chore: update `bytes` dependency to git master (#1796)
Tokio will track changes to bytes until 0.5 is released.
Diffstat (limited to 'tokio/tests/io_async_read.rs')
-rw-r--r-- | tokio/tests/io_async_read.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/tokio/tests/io_async_read.rs b/tokio/tests/io_async_read.rs index 007e5403..0b9509e1 100644 --- a/tokio/tests/io_async_read.rs +++ b/tokio/tests/io_async_read.rs @@ -4,6 +4,7 @@ use tokio_test::{assert_ready_err, assert_ready_ok}; use bytes::{BufMut, BytesMut}; use std::io; +use std::mem::MaybeUninit; use std::pin::Pin; use std::task::{Context, Poll}; @@ -75,12 +76,10 @@ fn read_buf_no_capacity() { } } - // Can't create BytesMut w/ zero capacity, so fill it up - let mut buf = BytesMut::with_capacity(64); - buf.put(&[0; 64][..]); + let mut buf = [0u8; 0]; task::spawn(Rd).enter(|cx, rd| { - let n = assert_ready_ok!(rd.poll_read_buf(cx, &mut buf)); + let n = assert_ready_ok!(rd.poll_read_buf(cx, &mut &mut buf[..])); assert_eq!(0, n); }); } @@ -116,7 +115,7 @@ fn read_buf_uninitialized_ok() { struct Rd; impl AsyncRead for Rd { - unsafe fn prepare_uninitialized_buffer(&self, _: &mut [u8]) -> bool { + unsafe fn prepare_uninitialized_buffer(&self, _: &mut [MaybeUninit<u8>]) -> bool { false } @@ -134,7 +133,8 @@ fn read_buf_uninitialized_ok() { let mut buf = BytesMut::with_capacity(64); unsafe { - buf.bytes_mut()[0..11].copy_from_slice(b"hello world"); + let b: &mut [u8] = std::mem::transmute(buf.bytes_mut()); + b[0..11].copy_from_slice(b"hello world"); } task::spawn(Rd).enter(|cx, rd| { |