Skip to content

Commit 1c5b4cc

Browse files
committed
Relax Unpin dep for Stream in collect
1 parent 2be2c2d commit 1c5b4cc

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ keywords = ["async", "await", "futures"]
1111
edition = "2018"
1212

1313
[dependencies]
14+
pin-utils = "=0.1.0-alpha.4"
1415

1516
[dependencies.futures]
1617
version = "=0.3.0-alpha.13"

src/stream.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use futures::stream::Stream;
22
use core::pin::Pin;
3+
use pin_utils::pin_mut;
34

45
pub async fn next<St>(stream: &mut St) -> Option<St::Item>
56
where St: Stream + Unpin,
@@ -11,10 +12,11 @@ pub async fn next<St>(stream: &mut St) -> Option<St::Item>
1112
await!(future_next)
1213
}
1314

14-
pub async fn collect<St, C>(mut stream: St) -> C
15-
where St: Stream + Unpin,
15+
pub async fn collect<St, C>(stream: St) -> C
16+
where St: Stream,
1617
C: Default + Extend<St::Item>
1718
{
19+
pin_mut!(stream);
1820
let mut collection = C::default();
1921
while let Some(item) = await!(next(&mut stream)) {
2022
collection.extend(Some(item));

0 commit comments

Comments
 (0)