Files
tokio/tokio-io/tests/read_to_string.rs
T
tmiasko 53a94c025d io: implement AsyncBufRead for &[u8] and Cursor (#1397)
* `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>`
2019-08-07 12:57:37 -07:00

16 lines
364 B
Rust

#![deny(warnings, rust_2018_idioms)]
#![feature(async_await)]
use tokio_io::AsyncReadExt;
use tokio_test::assert_ok;
#[tokio::test]
async fn read_to_string() {
let mut buf = String::new();
let mut rd: &[u8] = b"hello world";
let n = assert_ok!(rd.read_to_string(&mut buf).await);
assert_eq!(n, 11);
assert_eq!(buf[..], "hello world"[..]);
}