Skip to content

Commit f0875d2

Browse files
committed
Cleaning up stream pinning.
1 parent f611cec commit f0875d2

File tree

20 files changed

+5
-67
lines changed

20 files changed

+5
-67
lines changed

Diff for: src/collections/binary_heap/from_stream.rs

-2
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

Diff for: src/collections/btree_map/from_stream.rs

-2
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

Diff for: src/collections/btree_set/from_stream.rs

-2
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

Diff for: src/collections/hash_map/from_stream.rs

-2
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

Diff for: src/collections/hash_set/from_stream.rs

-2
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

Diff for: src/collections/linked_list/from_stream.rs

-2
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

Diff for: src/collections/vec_deque/from_stream.rs

-2
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

Diff for: src/option/from_stream.rs

-2
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;

Diff for: src/option/product.rs

-2
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;

Diff for: src/option/sum.rs

-2
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;

Diff for: src/path/pathbuf.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,6 @@ impl<P: AsRef<Path>> stream::Extend<P> for PathBuf {
327327
let stream = stream.into_stream();
328328

329329
Box::pin(async move {
330-
pin_utils::pin_mut!(stream);
331-
332330
while let Some(item) = stream.next().await {
333331
self.push(item.as_ref());
334332
}
@@ -342,10 +340,9 @@ impl<'b, P: AsRef<Path> + 'b> FromStream<P> for PathBuf {
342340
fn from_stream<'a, S: IntoStream<Item = P> + 'a>(
343341
stream: S,
344342
) -> Pin<Box<dyn Future<Output = Self> + 'a>> {
345-
Box::pin(async move {
346-
let stream = stream.into_stream();
347-
pin_utils::pin_mut!(stream);
343+
let stream = stream.into_stream();
348344

345+
Box::pin(async move {
349346
let mut out = Self::new();
350347
stream::extend(&mut out, stream).await;
351348
out

Diff for: src/result/from_stream.rs

-2
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;

Diff for: src/result/product.rs

-2
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;

Diff for: src/result/sum.rs

-2
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;

Diff for: src/stream/from_fn.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ impl<F> Unpin for FromFn<F> {}
3030
/// use async_std::stream;
3131
///
3232
/// let mut count = 0u8;
33-
/// let s = stream::from_fn(|| {
33+
/// let mut s = stream::from_fn(|| {
3434
/// count += 1;
3535
/// if count > 3 {
3636
/// None
@@ -39,7 +39,6 @@ impl<F> Unpin for FromFn<F> {}
3939
/// }
4040
/// });
4141
///
42-
/// pin_utils::pin_mut!(s);
4342
/// assert_eq!(s.next().await, Some(1));
4443
/// assert_eq!(s.next().await, Some(2));
4544
/// assert_eq!(s.next().await, Some(3));

Diff for: src/stream/repeat_with.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ impl<F> Unpin for RepeatWith<F> {}
2828
/// use async_std::prelude::*;
2929
/// use async_std::stream;
3030
///
31-
/// let s = stream::repeat_with(|| 1);
32-
///
33-
/// pin_utils::pin_mut!(s);
31+
/// let mut s = stream::repeat_with(|| 1);
3432
///
3533
/// assert_eq!(s.next().await, Some(1));
3634
/// assert_eq!(s.next().await, Some(1));

Diff for: src/string/extend.rs

-10
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ impl stream::Extend<char> for String {
1313
self.reserve(stream.size_hint().0);
1414

1515
Box::pin(async move {
16-
pin_utils::pin_mut!(stream);
17-
1816
while let Some(item) = stream.next().await {
1917
self.push(item);
2018
}
@@ -30,8 +28,6 @@ impl<'b> stream::Extend<&'b char> for String {
3028
let stream = stream.into_stream();
3129

3230
Box::pin(async move {
33-
pin_utils::pin_mut!(stream);
34-
3531
while let Some(item) = stream.next().await {
3632
self.push(*item);
3733
}
@@ -47,8 +43,6 @@ impl<'b> stream::Extend<&'b str> for String {
4743
let stream = stream.into_stream();
4844

4945
Box::pin(async move {
50-
pin_utils::pin_mut!(stream);
51-
5246
while let Some(item) = stream.next().await {
5347
self.push_str(item);
5448
}
@@ -64,8 +58,6 @@ impl stream::Extend<String> for String {
6458
let stream = stream.into_stream();
6559

6660
Box::pin(async move {
67-
pin_utils::pin_mut!(stream);
68-
6961
while let Some(item) = stream.next().await {
7062
self.push_str(&item);
7163
}
@@ -81,8 +73,6 @@ impl<'b> stream::Extend<Cow<'b, str>> for String {
8173
let stream = stream.into_stream();
8274

8375
Box::pin(async move {
84-
pin_utils::pin_mut!(stream);
85-
8676
while let Some(item) = stream.next().await {
8777
self.push_str(&item);
8878
}

Diff for: src/string/from_stream.rs

-10
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

Diff for: src/unit/extend.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ 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 {
13-
pin_utils::pin_mut!(stream);
1414
while let Some(_) = stream.next().await {}
1515
})
1616
}

Diff for: src/vec/from_stream.rs

-10
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)