From f0bf66d0df2a1f3d1885d45464085629b8d0b3d2 Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Sun, 29 Sep 2019 00:38:49 +0900 Subject: [PATCH 1/2] Update futures-preview to 0.3.0-alpha.19 --- Cargo.toml | 14 +++++++------- docs/src/tutorial/specification.md | 2 +- src/io/read/mod.rs | 9 +++++++++ src/io/read/read_to_end.rs | 2 +- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index f147404..766c740 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,8 +30,8 @@ async-task = "1.0.0" cfg-if = "0.1.9" crossbeam-channel = "0.3.9" crossbeam-deque = "0.7.1" -futures-core-preview = "=0.3.0-alpha.18" -futures-io-preview = "=0.3.0-alpha.18" +futures-core-preview = "=0.3.0-alpha.19" +futures-io-preview = "=0.3.0-alpha.19" futures-timer = "0.4.0" lazy_static = "1.4.0" log = { version = "0.4.8", features = ["kv_unstable"] } @@ -48,11 +48,11 @@ broadcaster = { version = "0.2.6", optional = true, default-features = false, fe femme = "1.2.0" surf = "1.0.2" tempdir = "0.3.7" +futures-preview = { version = "=0.3.0-alpha.19", features = ["async-await"] } # These are used by the book for examples -futures-channel-preview = "=0.3.0-alpha.18" -futures-util-preview = "=0.3.0-alpha.18" +futures-channel-preview = "=0.3.0-alpha.19" +futures-util-preview = "=0.3.0-alpha.19" -[dev-dependencies.futures-preview] -version = "=0.3.0-alpha.18" -features = ["std", "nightly", "async-await"] +[patch.crates-io] +surf = { git = "https://github.com/taiki-e/surf", branch = "futures" } diff --git a/docs/src/tutorial/specification.md b/docs/src/tutorial/specification.md index ce2abcb..bda4576 100644 --- a/docs/src/tutorial/specification.md +++ b/docs/src/tutorial/specification.md @@ -50,6 +50,6 @@ Add the following lines to `Cargo.toml`: ```toml [dependencies] -futures-preview = { version = "0.3.0-alpha.18", features = [ "async-await", "nightly" ] } +futures-preview = { version = "0.3.0-alpha.19", features = [ "async-await" ] } async-std = "0.99" ``` diff --git a/src/io/read/mod.rs b/src/io/read/mod.rs index 9c81f95..6fd95c1 100644 --- a/src/io/read/mod.rs +++ b/src/io/read/mod.rs @@ -461,6 +461,15 @@ extension_trait! { } } +/// Initializes a buffer if necessary. +/// +/// Currently, a buffer is always initialized because `read_initializer` +/// feature is not stable. +#[inline] +unsafe fn initialize(_reader: &R, buf: &mut [u8]) { + std::ptr::write_bytes(buf.as_mut_ptr(), 0, buf.len()) +} + #[cfg(test)] mod tests { use crate::io; diff --git a/src/io/read/read_to_end.rs b/src/io/read/read_to_end.rs index 331f26f..d76ee8c 100644 --- a/src/io/read/read_to_end.rs +++ b/src/io/read/read_to_end.rs @@ -64,7 +64,7 @@ pub fn read_to_end_internal( g.buf.reserve(32); let capacity = g.buf.capacity(); g.buf.set_len(capacity); - rd.initializer().initialize(&mut g.buf[g.len..]); + super::initialize(&rd, &mut g.buf[g.len..]); } } From 77ebedd44c5afa518fa7608990741bc1fe563cc6 Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Wed, 2 Oct 2019 02:23:41 +0900 Subject: [PATCH 2/2] Temporarily deactivate the surf example --- Cargo.toml | 5 +---- examples/surf-web.rs | 4 ++++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 766c740..5b988bb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,13 +46,10 @@ broadcaster = { version = "0.2.6", optional = true, default-features = false, fe [dev-dependencies] femme = "1.2.0" -surf = "1.0.2" +# surf = "1.0.2" tempdir = "0.3.7" futures-preview = { version = "=0.3.0-alpha.19", features = ["async-await"] } # These are used by the book for examples futures-channel-preview = "=0.3.0-alpha.19" futures-util-preview = "=0.3.0-alpha.19" - -[patch.crates-io] -surf = { git = "https://github.com/taiki-e/surf", branch = "futures" } diff --git a/examples/surf-web.rs b/examples/surf-web.rs index fd19c29..b3101d1 100644 --- a/examples/surf-web.rs +++ b/examples/surf-web.rs @@ -1,3 +1,4 @@ +/* TODO: Once the next version of surf released, re-enable this example. //! Sends an HTTP request to the Rust website. use async_std::task; @@ -17,3 +18,6 @@ fn main() -> Result<(), surf::Exception> { Ok(()) }) } +*/ + +fn main() {}