From ff41108834ab8fdf92e5c337b46637ba696d89c7 Mon Sep 17 00:00:00 2001 From: Lucio Franco Date: Fri, 2 Aug 2019 15:23:44 -0400 Subject: io: move io helpers back into `tokio-io` (#1377) Utilities are made optional with a feature flag. --- tokio/tests/io_read_to_string.rs | 40 ---------------------------------------- 1 file changed, 40 deletions(-) delete mode 100644 tokio/tests/io_read_to_string.rs (limited to 'tokio/tests/io_read_to_string.rs') diff --git a/tokio/tests/io_read_to_string.rs b/tokio/tests/io_read_to_string.rs deleted file mode 100644 index 4bbee177..00000000 --- a/tokio/tests/io_read_to_string.rs +++ /dev/null @@ -1,40 +0,0 @@ -#![deny(warnings, rust_2018_idioms)] -#![feature(async_await)] - -use tokio::io::{AsyncRead, AsyncReadExt}; -use tokio_test::assert_ok; - -use std::pin::Pin; -use std::task::{Context, Poll}; -use std::{cmp, io}; - -#[tokio::test] -async fn read_to_string() { - struct Rd { - val: &'static [u8], - } - - impl AsyncRead for Rd { - fn poll_read( - mut self: Pin<&mut Self>, - _cx: &mut Context<'_>, - buf: &mut [u8], - ) -> Poll> { - let me = &mut *self; - let len = cmp::min(buf.len(), me.val.len()); - - buf[..len].copy_from_slice(&me.val[..len]); - me.val = &me.val[len..]; - Poll::Ready(Ok(len)) - } - } - - let mut buf = String::new(); - let mut rd = Rd { - val: b"hello world", - }; - - let n = assert_ok!(rd.read_to_string(&mut buf).await); - assert_eq!(n, 11); - assert_eq!(buf[..], "hello world"[..]); -} -- cgit v1.2.3