From f6b22f5ec1bf09a1d14b044cb9a0e833406c9698 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 7 Nov 2020 11:04:01 +0100 Subject: Add IntoStream for all Iterator<_> Signed-off-by: Matthias Beyer --- tokio/src/stream/mod.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tokio/src/stream/mod.rs b/tokio/src/stream/mod.rs index 6bf42324..f14e59f8 100644 --- a/tokio/src/stream/mod.rs +++ b/tokio/src/stream/mod.rs @@ -926,6 +926,18 @@ pub trait StreamExt: Stream { impl StreamExt for St where St: Stream {} +pub trait IntoStream: std::iter::Iterator + Sized { + fn into_stream(self) -> Iter; +} + +impl IntoStream for I + where I: std::iter::Iterator + Sized +{ + fn into_stream(self) -> Iter { + iter(self) + } +} + /// Merge the size hints from two streams. fn merge_size_hints( (left_low, left_high): (usize, Option), -- cgit v1.2.3