Skip to content

Commit 6338341

Browse files
authored
Merge pull request async-rs#520 from gierlachg/stream_pinning
Cleaning up stream pinning.
2 parents f611cec + e442eba commit 6338341

File tree

18 files changed

+5
-49
lines changed

18 files changed

+5
-49
lines changed

src/collections/binary_heap/from_stream.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ impl<T: Ord> FromStream<T> for BinaryHeap<T> {
1212
let stream = stream.into_stream();
1313

1414
Box::pin(async move {
15-
pin_utils::pin_mut!(stream);
16-
1715
let mut out = BinaryHeap::new();
1816
stream::extend(&mut out, stream).await;
1917
out

src/collections/btree_map/from_stream.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ impl<K: Ord, V> FromStream<(K, V)> for BTreeMap<K, V> {
1212
let stream = stream.into_stream();
1313

1414
Box::pin(async move {
15-
pin_utils::pin_mut!(stream);
16-
1715
let mut out = BTreeMap::new();
1816
stream::extend(&mut out, stream).await;
1917
out

src/collections/btree_set/from_stream.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ impl<T: Ord> FromStream<T> for BTreeSet<T> {
1212
let stream = stream.into_stream();
1313

1414
Box::pin(async move {
15-
pin_utils::pin_mut!(stream);
16-
1715
let mut out = BTreeSet::new();
1816
stream::extend(&mut out, stream).await;
1917
out

src/collections/hash_map/from_stream.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ where
1717
let stream = stream.into_stream();
1818

1919
Box::pin(async move {
20-
pin_utils::pin_mut!(stream);
21-
2220
let mut out = HashMap::with_hasher(Default::default());
2321
stream::extend(&mut out, stream).await;
2422
out

src/collections/hash_set/from_stream.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ where
1717
let stream = stream.into_stream();
1818

1919
Box::pin(async move {
20-
pin_utils::pin_mut!(stream);
21-
2220
let mut out = HashSet::with_hasher(Default::default());
2321
stream::extend(&mut out, stream).await;
2422
out

src/collections/linked_list/from_stream.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ impl<T> FromStream<T> for LinkedList<T> {
1212
let stream = stream.into_stream();
1313

1414
Box::pin(async move {
15-
pin_utils::pin_mut!(stream);
16-
1715
let mut out = LinkedList::new();
1816
stream::extend(&mut out, stream).await;
1917
out

src/collections/vec_deque/from_stream.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ impl<T> FromStream<T> for VecDeque<T> {
1212
let stream = stream.into_stream();
1313

1414
Box::pin(async move {
15-
pin_utils::pin_mut!(stream);
16-
1715
let mut out = VecDeque::new();
1816
stream::extend(&mut out, stream).await;
1917
out

src/option/from_stream.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ where
1717
let stream = stream.into_stream();
1818

1919
Box::pin(async move {
20-
pin_utils::pin_mut!(stream);
21-
2220
// Using `scan` here because it is able to stop the stream early
2321
// if a failure occurs
2422
let mut found_error = false;

src/option/product.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ where
3939
where S: Stream<Item = Option<U>> + 'a
4040
{
4141
Box::pin(async move {
42-
pin_utils::pin_mut!(stream);
43-
4442
// Using `scan` here because it is able to stop the stream early
4543
// if a failure occurs
4644
let mut found_none = false;

src/option/sum.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ where
3434
where S: Stream<Item = Option<U>> + 'a
3535
{
3636
Box::pin(async move {
37-
pin_utils::pin_mut!(stream);
38-
3937
// Using `scan` here because it is able to stop the stream early
4038
// if a failure occurs
4139
let mut found_none = false;

src/path/pathbuf.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -342,10 +342,9 @@ impl<'b, P: AsRef<Path> + 'b> FromStream<P> for PathBuf {
342342
fn from_stream<'a, S: IntoStream<Item = P> + 'a>(
343343
stream: S,
344344
) -> Pin<Box<dyn Future<Output = Self> + 'a>> {
345-
Box::pin(async move {
346-
let stream = stream.into_stream();
347-
pin_utils::pin_mut!(stream);
345+
let stream = stream.into_stream();
348346

347+
Box::pin(async move {
349348
let mut out = Self::new();
350349
stream::extend(&mut out, stream).await;
351350
out

src/result/from_stream.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ where
1717
let stream = stream.into_stream();
1818

1919
Box::pin(async move {
20-
pin_utils::pin_mut!(stream);
21-
2220
// Using `scan` here because it is able to stop the stream early
2321
// if a failure occurs
2422
let mut found_error = None;

src/result/product.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ where
3939
where S: Stream<Item = Result<U, E>> + 'a
4040
{
4141
Box::pin(async move {
42-
pin_utils::pin_mut!(stream);
43-
4442
// Using `scan` here because it is able to stop the stream early
4543
// if a failure occurs
4644
let mut found_error = None;

src/result/sum.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ where
3939
where S: Stream<Item = Result<U, E>> + 'a
4040
{
4141
Box::pin(async move {
42-
pin_utils::pin_mut!(stream);
43-
4442
// Using `scan` here because it is able to stop the stream early
4543
// if a failure occurs
4644
let mut found_error = None;

src/stream/from_fn.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ impl<F> Unpin for FromFn<F> {}
4040
/// });
4141
///
4242
/// pin_utils::pin_mut!(s);
43+
///
4344
/// assert_eq!(s.next().await, Some(1));
4445
/// assert_eq!(s.next().await, Some(2));
4546
/// assert_eq!(s.next().await, Some(3));

src/string/from_stream.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ impl FromStream<char> for String {
1212
let stream = stream.into_stream();
1313

1414
Box::pin(async move {
15-
pin_utils::pin_mut!(stream);
16-
1715
let mut out = String::new();
1816
stream::extend(&mut out, stream).await;
1917
out
@@ -29,8 +27,6 @@ impl<'b> FromStream<&'b char> for String {
2927
let stream = stream.into_stream();
3028

3129
Box::pin(async move {
32-
pin_utils::pin_mut!(stream);
33-
3430
let mut out = String::new();
3531
stream::extend(&mut out, stream).await;
3632
out
@@ -46,8 +42,6 @@ impl<'b> FromStream<&'b str> for String {
4642
let stream = stream.into_stream();
4743

4844
Box::pin(async move {
49-
pin_utils::pin_mut!(stream);
50-
5145
let mut out = String::new();
5246
stream::extend(&mut out, stream).await;
5347
out
@@ -63,8 +57,6 @@ impl FromStream<String> for String {
6357
let stream = stream.into_stream();
6458

6559
Box::pin(async move {
66-
pin_utils::pin_mut!(stream);
67-
6860
let mut out = String::new();
6961
stream::extend(&mut out, stream).await;
7062
out
@@ -80,8 +72,6 @@ impl<'b> FromStream<Cow<'b, str>> for String {
8072
let stream = stream.into_stream();
8173

8274
Box::pin(async move {
83-
pin_utils::pin_mut!(stream);
84-
8575
let mut out = String::new();
8676
stream::extend(&mut out, stream).await;
8777
out

src/unit/extend.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ impl stream::Extend<()> for () {
99
stream: T,
1010
) -> Pin<Box<dyn Future<Output = ()> + 'a>> {
1111
let stream = stream.into_stream();
12+
1213
Box::pin(async move {
1314
pin_utils::pin_mut!(stream);
15+
1416
while let Some(_) = stream.next().await {}
1517
})
1618
}

src/vec/from_stream.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ impl<T> FromStream<T> for Vec<T> {
1717
let stream = stream.into_stream();
1818

1919
Box::pin(async move {
20-
pin_utils::pin_mut!(stream);
21-
2220
let mut out = vec![];
2321
stream::extend(&mut out, stream).await;
2422
out
@@ -34,8 +32,6 @@ impl<'b, T: Clone> FromStream<T> for Cow<'b, [T]> {
3432
let stream = stream.into_stream();
3533

3634
Box::pin(async move {
37-
pin_utils::pin_mut!(stream);
38-
3935
Cow::Owned(FromStream::from_stream(stream).await)
4036
})
4137
}
@@ -49,8 +45,6 @@ impl<T> FromStream<T> for Box<[T]> {
4945
let stream = stream.into_stream();
5046

5147
Box::pin(async move {
52-
pin_utils::pin_mut!(stream);
53-
5448
Vec::from_stream(stream).await.into_boxed_slice()
5549
})
5650
}
@@ -64,8 +58,6 @@ impl<T> FromStream<T> for Rc<[T]> {
6458
let stream = stream.into_stream();
6559

6660
Box::pin(async move {
67-
pin_utils::pin_mut!(stream);
68-
6961
Vec::from_stream(stream).await.into()
7062
})
7163
}
@@ -79,8 +71,6 @@ impl<T> FromStream<T> for Arc<[T]> {
7971
let stream = stream.into_stream();
8072

8173
Box::pin(async move {
82-
pin_utils::pin_mut!(stream);
83-
8474
Vec::from_stream(stream).await.into()
8575
})
8676
}

0 commit comments

Comments
 (0)