1 #![warn(rust_2018_idioms)] 2 #![cfg(feature = "full")] 3 4 use tokio::io::AsyncReadExt; 5 use tokio_test::assert_ok; 6 7 #[tokio::test] take()8async fn take() { 9 let mut buf = [0; 6]; 10 let rd: &[u8] = b"hello world"; 11 12 let mut rd = rd.take(4); 13 let n = assert_ok!(rd.read(&mut buf).await); 14 assert_eq!(n, 4); 15 assert_eq!(&buf, &b"hell\0\0"[..]); 16 } 17