From 987ba7373cf95c570bf23768c6021f7a7508286e Mon Sep 17 00:00:00 2001 From: Carl Lerche Date: Sat, 26 Oct 2019 08:02:49 -0700 Subject: io: move into `tokio` crate (#1691) A step towards collapsing Tokio sub crates into a single `tokio` crate (#1318). The `io` implementation is now provided by the main `tokio` crate. Functionality can be opted out of by using the various net related feature flags. --- tokio/tests/io_take.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 tokio/tests/io_take.rs (limited to 'tokio/tests/io_take.rs') diff --git a/tokio/tests/io_take.rs b/tokio/tests/io_take.rs new file mode 100644 index 00000000..7b3363e0 --- /dev/null +++ b/tokio/tests/io_take.rs @@ -0,0 +1,15 @@ +#![warn(rust_2018_idioms)] + +use tokio::io::AsyncReadExt; +use tokio_test::assert_ok; + +#[tokio::test] +async fn take() { + let mut buf = [0; 6]; + let rd: &[u8] = b"hello world"; + + let mut rd = rd.take(4); + let n = assert_ok!(rd.read(&mut buf).await); + assert_eq!(n, 4); + assert_eq!(&buf, &b"hell\0\0"[..]); +} -- cgit v1.2.3