From 73e3a512a6ab82b3eaab5795347f40282ffc4698 Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Thu, 7 Nov 2019 11:00:08 +0100 Subject: [PATCH] Update to futures 0.3 --- Cargo.toml | 2 +- src/codec/bytes.rs | 2 +- src/framed.rs | 2 +- src/lib.rs | 2 +- tests/bytes.rs | 4 ++-- tests/framed_read.rs | 4 ++-- tests/framed_write.rs | 13 ++++++------- tests/lines.rs | 2 +- 8 files changed, 15 insertions(+), 16 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 1033285..b920c42 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,5 +14,5 @@ categories = ["asynchronous", "network-programming"] [dependencies] bytes = "0.4.12" -futures-preview = "0.3.0-alpha.17" +futures = "0.3.0" memchr = "2.2.1" diff --git a/src/codec/bytes.rs b/src/codec/bytes.rs index 283fb43..8a1aae8 100644 --- a/src/codec/bytes.rs +++ b/src/codec/bytes.rs @@ -10,7 +10,7 @@ use std::io::Error; /// #![feature(async_await)] /// use bytes::Bytes; /// use futures::{SinkExt, TryStreamExt}; -/// use std::io::Cursor; +/// use futures::io::Cursor; /// use futures_codec::{BytesCodec, Framed}; /// /// async move { diff --git a/src/framed.rs b/src/framed.rs index 6cf2e82..56b3564 100644 --- a/src/framed.rs +++ b/src/framed.rs @@ -68,7 +68,7 @@ impl AsyncWrite for Fuse { /// #![feature(async_await)] /// use bytes::Bytes; /// use futures::{executor, SinkExt, TryStreamExt}; -/// use std::io::Cursor; +/// use futures::io::Cursor; /// use futures_codec::{BytesCodec, Framed}; /// /// executor::block_on(async move { diff --git a/src/lib.rs b/src/lib.rs index d615222..8ad0df7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -8,7 +8,7 @@ //! ``` //! # #![feature(async_await)] //! # use futures::{executor, SinkExt, TryStreamExt}; -//! # use std::io::Cursor; +//! # use futures::io::Cursor; //! use futures_codec::{LinesCodec, Framed}; //! //! async move { diff --git a/tests/bytes.rs b/tests/bytes.rs index f39d7ae..4050881 100644 --- a/tests/bytes.rs +++ b/tests/bytes.rs @@ -1,12 +1,12 @@ use futures::{executor, TryStreamExt}; use futures_codec::{BytesCodec, Framed}; -use std::io::Cursor; +use futures::io::Cursor; #[test] fn decodes() { let mut buf = [0u8; 32]; let expected = buf.clone(); - let cur = Cursor::new(&mut buf); + let cur = Cursor::new(&mut buf[..]); let mut framed = Framed::new(cur, BytesCodec {}); let read = executor::block_on(framed.try_next()).unwrap().unwrap(); diff --git a/tests/framed_read.rs b/tests/framed_read.rs index 7f51cc3..de6e820 100644 --- a/tests/framed_read.rs +++ b/tests/framed_read.rs @@ -1,10 +1,10 @@ use futures::executor; use futures::stream::StreamExt; -use futures::task::Context; -use futures::{AsyncRead, Poll}; +use futures::AsyncRead; use futures_codec::{FramedRead, LinesCodec}; use std::io; use std::pin::Pin; +use std::task::{Context, Poll}; // Sends two lines at once, then nothing else forever struct MockBurstySender { diff --git a/tests/framed_write.rs b/tests/framed_write.rs index 747160d..74c7518 100644 --- a/tests/framed_write.rs +++ b/tests/framed_write.rs @@ -1,13 +1,11 @@ use bytes::Bytes; use core::iter::Iterator; -use futures::io::AsyncWrite; +use futures::io::{AsyncWrite, Cursor}; use futures::sink::SinkExt; -use futures::task::Context; -use futures::Poll; -use futures::{executor, stream}; +use futures::{executor, stream, stream::StreamExt}; use futures_codec::{BytesCodec, FramedWrite, LinesCodec}; -use std::io::Cursor; use std::pin::Pin; +use std::task::{Context, Poll}; // An iterator which outputs a single zero byte up to limit times struct ZeroBytes { @@ -67,7 +65,8 @@ fn line_write() { #[test] fn line_write_to_eof() { - let curs = Cursor::new(vec![0u8; 16]); + let mut buf = [0u8; 16]; + let curs = Cursor::new(&mut buf[..]); let mut framer = FramedWrite::new(curs, LinesCodec {}); let _err = executor::block_on(framer.send("This will fill up the buffer\n".to_owned())).unwrap_err(); @@ -82,7 +81,7 @@ fn send_high_water_mark() { let mut stream = stream::iter(ZeroBytes { count: 0, limit: 999, - }); + }).map(Ok); // sink will eat whatever it receives let io = AsyncWriteNull { diff --git a/tests/lines.rs b/tests/lines.rs index 3791059..e34fdd4 100644 --- a/tests/lines.rs +++ b/tests/lines.rs @@ -1,6 +1,6 @@ use futures::{executor, TryStreamExt}; use futures_codec::{FramedRead, LinesCodec}; -use std::io::Cursor; +use futures::io::Cursor; #[test] fn it_works() {