Skip to content

Cleaning up stream pinning. #520

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/collections/binary_heap/from_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ impl<T: Ord> FromStream<T> for BinaryHeap<T> {
let stream = stream.into_stream();

Box::pin(async move {
pin_utils::pin_mut!(stream);

let mut out = BinaryHeap::new();
stream::extend(&mut out, stream).await;
out
Expand Down
2 changes: 0 additions & 2 deletions src/collections/btree_map/from_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ impl<K: Ord, V> FromStream<(K, V)> for BTreeMap<K, V> {
let stream = stream.into_stream();

Box::pin(async move {
pin_utils::pin_mut!(stream);

let mut out = BTreeMap::new();
stream::extend(&mut out, stream).await;
out
Expand Down
2 changes: 0 additions & 2 deletions src/collections/btree_set/from_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ impl<T: Ord> FromStream<T> for BTreeSet<T> {
let stream = stream.into_stream();

Box::pin(async move {
pin_utils::pin_mut!(stream);

let mut out = BTreeSet::new();
stream::extend(&mut out, stream).await;
out
Expand Down
2 changes: 0 additions & 2 deletions src/collections/hash_map/from_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ where
let stream = stream.into_stream();

Box::pin(async move {
pin_utils::pin_mut!(stream);

let mut out = HashMap::with_hasher(Default::default());
stream::extend(&mut out, stream).await;
out
Expand Down
2 changes: 0 additions & 2 deletions src/collections/hash_set/from_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ where
let stream = stream.into_stream();

Box::pin(async move {
pin_utils::pin_mut!(stream);

let mut out = HashSet::with_hasher(Default::default());
stream::extend(&mut out, stream).await;
out
Expand Down
2 changes: 0 additions & 2 deletions src/collections/linked_list/from_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ impl<T> FromStream<T> for LinkedList<T> {
let stream = stream.into_stream();

Box::pin(async move {
pin_utils::pin_mut!(stream);

let mut out = LinkedList::new();
stream::extend(&mut out, stream).await;
out
Expand Down
2 changes: 0 additions & 2 deletions src/collections/vec_deque/from_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ impl<T> FromStream<T> for VecDeque<T> {
let stream = stream.into_stream();

Box::pin(async move {
pin_utils::pin_mut!(stream);

let mut out = VecDeque::new();
stream::extend(&mut out, stream).await;
out
Expand Down
2 changes: 0 additions & 2 deletions src/option/from_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ where
let stream = stream.into_stream();

Box::pin(async move {
pin_utils::pin_mut!(stream);

// Using `scan` here because it is able to stop the stream early
// if a failure occurs
let mut found_error = false;
Expand Down
2 changes: 0 additions & 2 deletions src/option/product.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ where
where S: Stream<Item = Option<U>> + 'a
{
Box::pin(async move {
pin_utils::pin_mut!(stream);

// Using `scan` here because it is able to stop the stream early
// if a failure occurs
let mut found_none = false;
Expand Down
2 changes: 0 additions & 2 deletions src/option/sum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ where
where S: Stream<Item = Option<U>> + 'a
{
Box::pin(async move {
pin_utils::pin_mut!(stream);

// Using `scan` here because it is able to stop the stream early
// if a failure occurs
let mut found_none = false;
Expand Down
5 changes: 2 additions & 3 deletions src/path/pathbuf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,10 +342,9 @@ impl<'b, P: AsRef<Path> + 'b> FromStream<P> for PathBuf {
fn from_stream<'a, S: IntoStream<Item = P> + 'a>(
stream: S,
) -> Pin<Box<dyn Future<Output = Self> + 'a>> {
Box::pin(async move {
let stream = stream.into_stream();
pin_utils::pin_mut!(stream);
let stream = stream.into_stream();

Box::pin(async move {
let mut out = Self::new();
stream::extend(&mut out, stream).await;
out
Expand Down
2 changes: 0 additions & 2 deletions src/result/from_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ where
let stream = stream.into_stream();

Box::pin(async move {
pin_utils::pin_mut!(stream);

// Using `scan` here because it is able to stop the stream early
// if a failure occurs
let mut found_error = None;
Expand Down
2 changes: 0 additions & 2 deletions src/result/product.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ where
where S: Stream<Item = Result<U, E>> + 'a
{
Box::pin(async move {
pin_utils::pin_mut!(stream);

// Using `scan` here because it is able to stop the stream early
// if a failure occurs
let mut found_error = None;
Expand Down
2 changes: 0 additions & 2 deletions src/result/sum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ where
where S: Stream<Item = Result<U, E>> + 'a
{
Box::pin(async move {
pin_utils::pin_mut!(stream);

// Using `scan` here because it is able to stop the stream early
// if a failure occurs
let mut found_error = None;
Expand Down
1 change: 1 addition & 0 deletions src/stream/from_fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ impl<F> Unpin for FromFn<F> {}
/// });
///
/// pin_utils::pin_mut!(s);
///
/// assert_eq!(s.next().await, Some(1));
/// assert_eq!(s.next().await, Some(2));
/// assert_eq!(s.next().await, Some(3));
Expand Down
10 changes: 0 additions & 10 deletions src/string/from_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ impl FromStream<char> for String {
let stream = stream.into_stream();

Box::pin(async move {
pin_utils::pin_mut!(stream);

let mut out = String::new();
stream::extend(&mut out, stream).await;
out
Expand All @@ -29,8 +27,6 @@ impl<'b> FromStream<&'b char> for String {
let stream = stream.into_stream();

Box::pin(async move {
pin_utils::pin_mut!(stream);

let mut out = String::new();
stream::extend(&mut out, stream).await;
out
Expand All @@ -46,8 +42,6 @@ impl<'b> FromStream<&'b str> for String {
let stream = stream.into_stream();

Box::pin(async move {
pin_utils::pin_mut!(stream);

let mut out = String::new();
stream::extend(&mut out, stream).await;
out
Expand All @@ -63,8 +57,6 @@ impl FromStream<String> for String {
let stream = stream.into_stream();

Box::pin(async move {
pin_utils::pin_mut!(stream);

let mut out = String::new();
stream::extend(&mut out, stream).await;
out
Expand All @@ -80,8 +72,6 @@ impl<'b> FromStream<Cow<'b, str>> for String {
let stream = stream.into_stream();

Box::pin(async move {
pin_utils::pin_mut!(stream);

let mut out = String::new();
stream::extend(&mut out, stream).await;
out
Expand Down
2 changes: 2 additions & 0 deletions src/unit/extend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ impl stream::Extend<()> for () {
stream: T,
) -> Pin<Box<dyn Future<Output = ()> + 'a>> {
let stream = stream.into_stream();

Box::pin(async move {
pin_utils::pin_mut!(stream);

while let Some(_) = stream.next().await {}
})
}
Expand Down
10 changes: 0 additions & 10 deletions src/vec/from_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ impl<T> FromStream<T> for Vec<T> {
let stream = stream.into_stream();

Box::pin(async move {
pin_utils::pin_mut!(stream);

let mut out = vec![];
stream::extend(&mut out, stream).await;
out
Expand All @@ -34,8 +32,6 @@ impl<'b, T: Clone> FromStream<T> for Cow<'b, [T]> {
let stream = stream.into_stream();

Box::pin(async move {
pin_utils::pin_mut!(stream);

Cow::Owned(FromStream::from_stream(stream).await)
})
}
Expand All @@ -49,8 +45,6 @@ impl<T> FromStream<T> for Box<[T]> {
let stream = stream.into_stream();

Box::pin(async move {
pin_utils::pin_mut!(stream);

Vec::from_stream(stream).await.into_boxed_slice()
})
}
Expand All @@ -64,8 +58,6 @@ impl<T> FromStream<T> for Rc<[T]> {
let stream = stream.into_stream();

Box::pin(async move {
pin_utils::pin_mut!(stream);

Vec::from_stream(stream).await.into()
})
}
Expand All @@ -79,8 +71,6 @@ impl<T> FromStream<T> for Arc<[T]> {
let stream = stream.into_stream();

Box::pin(async move {
pin_utils::pin_mut!(stream);

Vec::from_stream(stream).await.into()
})
}
Expand Down