mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-24 00:00:11 +02:00
* `impl AsyncRead for &[u8]` * `impl AsyncBufRead for &[u8]` * `impl<T: AsRef<[u8]> + Unpin> AsyncRead for Cursor<T>` * `impl<T: AsRef<[u8]> + Unpin> AsyncBufRead for Cursor<T>`
16 lines
360 B
Rust
16 lines
360 B
Rust
#![deny(warnings, rust_2018_idioms)]
|
|
#![feature(async_await)]
|
|
|
|
use tokio_io::AsyncReadExt;
|
|
use tokio_test::assert_ok;
|
|
|
|
#[tokio::test]
|
|
async fn read_exact() {
|
|
let mut buf = Box::new([0; 8]);
|
|
let mut rd: &[u8] = b"hello world";
|
|
|
|
let n = assert_ok!(rd.read_exact(&mut buf[..]).await);
|
|
assert_eq!(n, 8);
|
|
assert_eq!(buf[..], b"hello wo"[..]);
|
|
}
|