From 9efa0491e142e4671ecf44fe3c573cccbf01587a Mon Sep 17 00:00:00 2001 From: David LeGare Date: Wed, 2 Mar 2022 16:21:06 +0000 Subject: Update tokio-stream to 0.1.8 Test: cd external/rust/crates && atest --host -c Change-Id: I50075ad0877aeb06bdc1f87903025b08ba6ac644 --- .cargo_vcs_info.json | 2 +- Android.bp | 2 +- CHANGELOG.md | 10 ++++++++++ Cargo.toml | 14 +++++++------- Cargo.toml.orig | 9 +++++++-- METADATA | 10 +++++----- src/stream_map.rs | 17 +++++++++++++++++ src/wrappers.rs | 13 ++----------- src/wrappers/broadcast.rs | 6 ++++++ src/wrappers/mpsc_bounded.rs | 6 ++++++ src/wrappers/mpsc_unbounded.rs | 6 ++++++ src/wrappers/watch.rs | 8 +++++++- tests/watch.rs | 2 ++ 13 files changed, 77 insertions(+), 28 deletions(-) diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json index 749a519..f2822a6 100644 --- a/.cargo_vcs_info.json +++ b/.cargo_vcs_info.json @@ -1,5 +1,5 @@ { "git": { - "sha1": "5d61c997e9281e00f35c7ea426786996945f47f5" + "sha1": "d1a400912e82505c18c6c0c1f05cda06f334e201" } } diff --git a/Android.bp b/Android.bp index a784467..11ef3d4 100644 --- a/Android.bp +++ b/Android.bp @@ -23,7 +23,7 @@ rust_library { host_supported: true, crate_name: "tokio_stream", cargo_env_compat: true, - cargo_pkg_version: "0.1.7", + cargo_pkg_version: "0.1.8", srcs: ["src/lib.rs"], edition: "2018", features: [ diff --git a/CHANGELOG.md b/CHANGELOG.md index a0cdef0..4ef469e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +# 0.1.8 (October 29, 2021) + +- stream: add `From>` impl for receiver streams ([#4080]) +- stream: impl `FromIterator` for `StreamMap` ([#4052]) +- signal: make windows docs for signal module show up on unix builds ([#3770]) + +[#3770]: https://github.com/tokio-rs/tokio/pull/3770 +[#4052]: https://github.com/tokio-rs/tokio/pull/4052 +[#4080]: https://github.com/tokio-rs/tokio/pull/4080 + # 0.1.7 (July 7, 2021) ### Fixed diff --git a/Cargo.toml b/Cargo.toml index 5a8627a..699d94a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,26 +3,26 @@ # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies -# to registry (e.g., crates.io) dependencies +# to registry (e.g., crates.io) dependencies. # -# If you believe there's an error in this file please file an -# issue against the rust-lang/cargo repository. If you're -# editing this file be aware that the upstream Cargo.toml -# will likely look very different (and much more reasonable) +# If you are reading this file be aware that the original Cargo.toml +# will likely look very different (and much more reasonable). +# See Cargo.toml.orig for the original contents. [package] edition = "2018" name = "tokio-stream" -version = "0.1.7" +version = "0.1.8" authors = ["Tokio Contributors "] description = "Utilities to work with `Stream` and `tokio`.\n" homepage = "https://tokio.rs" -documentation = "https://docs.rs/tokio-stream/0.1.7/tokio_stream" +documentation = "https://docs.rs/tokio-stream/0.1.8/tokio_stream" categories = ["asynchronous"] license = "MIT" repository = "https://github.com/tokio-rs/tokio" [package.metadata.docs.rs] all-features = true +rustc-args = ["--cfg", "docsrs"] rustdoc-args = ["--cfg", "docsrs"] [dependencies.futures-core] version = "0.3.0" diff --git a/Cargo.toml.orig b/Cargo.toml.orig index 911657c..83f8551 100644 --- a/Cargo.toml.orig +++ b/Cargo.toml.orig @@ -6,13 +6,13 @@ name = "tokio-stream" # - Cargo.toml # - Update CHANGELOG.md. # - Create "tokio-stream-0.1.x" git tag. -version = "0.1.7" +version = "0.1.8" edition = "2018" authors = ["Tokio Contributors "] license = "MIT" repository = "https://github.com/tokio-rs/tokio" homepage = "https://tokio.rs" -documentation = "https://docs.rs/tokio-stream/0.1.7/tokio_stream" +documentation = "https://docs.rs/tokio-stream/0.1.8/tokio_stream" description = """ Utilities to work with `Stream` and `tokio`. """ @@ -44,3 +44,8 @@ proptest = "1" [package.metadata.docs.rs] all-features = true rustdoc-args = ["--cfg", "docsrs"] +# Issue #3770 +# +# This should allow `docsrs` to be read across projects, so that `tokio-stream` +# can pick up stubbed types exported by `tokio`. +rustc-args = ["--cfg", "docsrs"] diff --git a/METADATA b/METADATA index 8693d16..68e56e9 100644 --- a/METADATA +++ b/METADATA @@ -7,13 +7,13 @@ third_party { } url { type: ARCHIVE - value: "https://static.crates.io/crates/tokio-stream/tokio-stream-0.1.7.crate" + value: "https://static.crates.io/crates/tokio-stream/tokio-stream-0.1.8.crate" } - version: "0.1.7" + version: "0.1.8" license_type: NOTICE last_upgrade_date { - year: 2021 - month: 8 - day: 9 + year: 2022 + month: 3 + day: 1 } } diff --git a/src/stream_map.rs b/src/stream_map.rs index 9dc529a..80a521e 100644 --- a/src/stream_map.rs +++ b/src/stream_map.rs @@ -568,6 +568,23 @@ where } } +impl std::iter::FromIterator<(K, V)> for StreamMap +where + K: Hash + Eq, +{ + fn from_iter>(iter: T) -> Self { + let iterator = iter.into_iter(); + let (lower_bound, _) = iterator.size_hint(); + let mut stream_map = Self::with_capacity(lower_bound); + + for (key, value) in iterator { + stream_map.insert(key, value); + } + + stream_map + } +} + mod rand { use std::cell::Cell; diff --git a/src/wrappers.rs b/src/wrappers.rs index f2dc21f..62cabe4 100644 --- a/src/wrappers.rs +++ b/src/wrappers.rs @@ -1,13 +1,4 @@ //! Wrappers for Tokio types that implement `Stream`. -//! -#![cfg_attr( - unix, - doc = "You are viewing documentation built under unix. To view windows-specific wrappers, change to the `x86_64-pc-windows-msvc` platform." -)] -#![cfg_attr( - windows, - doc = "You are viewing documentation built under windows. To view unix-specific wrappers, change to the `x86_64-unknown-linux-gnu` platform." -)] /// Error types for the wrappers. pub mod errors { @@ -36,9 +27,9 @@ cfg_signal! { #[cfg(unix)] pub use signal_unix::SignalStream; - #[cfg(windows)] + #[cfg(any(windows, docsrs))] mod signal_windows; - #[cfg(windows)] + #[cfg(any(windows, docsrs))] pub use signal_windows::{CtrlCStream, CtrlBreakStream}; } diff --git a/src/wrappers/broadcast.rs b/src/wrappers/broadcast.rs index 3bddbb7..c8346a6 100644 --- a/src/wrappers/broadcast.rs +++ b/src/wrappers/broadcast.rs @@ -71,3 +71,9 @@ impl fmt::Debug for BroadcastStream { f.debug_struct("BroadcastStream").finish() } } + +impl From> for BroadcastStream { + fn from(recv: Receiver) -> Self { + Self::new(recv) + } +} diff --git a/src/wrappers/mpsc_bounded.rs b/src/wrappers/mpsc_bounded.rs index e4f9000..b536268 100644 --- a/src/wrappers/mpsc_bounded.rs +++ b/src/wrappers/mpsc_bounded.rs @@ -57,3 +57,9 @@ impl AsMut> for ReceiverStream { &mut self.inner } } + +impl From> for ReceiverStream { + fn from(recv: Receiver) -> Self { + Self::new(recv) + } +} diff --git a/src/wrappers/mpsc_unbounded.rs b/src/wrappers/mpsc_unbounded.rs index bc5f40c..54597b7 100644 --- a/src/wrappers/mpsc_unbounded.rs +++ b/src/wrappers/mpsc_unbounded.rs @@ -51,3 +51,9 @@ impl AsMut> for UnboundedReceiverStream { &mut self.inner } } + +impl From> for UnboundedReceiverStream { + fn from(recv: UnboundedReceiver) -> Self { + Self::new(recv) + } +} diff --git a/src/wrappers/watch.rs b/src/wrappers/watch.rs index 1daca10..bd3a18a 100644 --- a/src/wrappers/watch.rs +++ b/src/wrappers/watch.rs @@ -59,7 +59,7 @@ async fn make_future( (result, rx) } -impl WatchStream { +impl WatchStream { /// Create a new `WatchStream`. pub fn new(rx: Receiver) -> Self { Self { @@ -94,3 +94,9 @@ impl fmt::Debug for WatchStream { f.debug_struct("WatchStream").finish() } } + +impl From> for WatchStream { + fn from(recv: Receiver) -> Self { + Self::new(recv) + } +} diff --git a/tests/watch.rs b/tests/watch.rs index 92bcdf4..a56254e 100644 --- a/tests/watch.rs +++ b/tests/watch.rs @@ -1,3 +1,5 @@ +#![cfg(feature = "sync")] + use tokio::sync::watch; use tokio_stream::wrappers::WatchStream; use tokio_stream::StreamExt; -- cgit v1.2.3