summaryrefslogtreecommitdiffstats
path: root/third_party/rust/tokio/tests/io_chain.rs
blob: e2d59411a11292e3980b9ec1e1b6a28ec516708a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#![warn(rust_2018_idioms)]
#![cfg(feature = "full")]

use tokio::io::AsyncReadExt;
use tokio_test::assert_ok;

#[tokio::test]
async fn chain() {
    let mut buf = Vec::new();
    let rd1: &[u8] = b"hello ";
    let rd2: &[u8] = b"world";

    let mut rd = rd1.chain(rd2);
    assert_ok!(rd.read_to_end(&mut buf).await);
    assert_eq!(buf, b"hello world");
}