Skip to content
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

[tracking] streams #129

Open
yoshuawuyts opened this issue Aug 30, 2019 · 27 comments
Labels
Milestone

Comments

@yoshuawuyts
Copy link
Member

@yoshuawuyts yoshuawuyts commented Aug 30, 2019

With #125 out, it's probably worth looking at which other parts of std::iter we can port to async_std::stream. This issue is intended to track what's left for us to port.

Missing free functions

  • from_fn
  • repeat_with
  • successors

Missing traits

  • DoubleEndedStream
  • ExactSizeStream
  • Extend
  • FusedStream
  • Product
  • Sum

Missing stream methods

  • Stream::all
  • Stream::any
  • Stream::by_ref -> wip #538
  • Stream::chain
  • Stream::cloned
  • Stream::cmp
  • Stream::collect
  • Stream::copied
  • Stream::count
  • Stream::cycle
  • Stream::enumerate
  • Stream::eq
  • Stream::filter
  • Stream::filter_map
  • Stream::find
  • Stream::find_map
  • Stream::flat_map
  • Stream::flatten
  • Stream::fold
  • Stream::for_each
  • Stream::fuse
  • Stream::ge
  • Stream::gt
  • Stream::inspect
  • Stream::last
  • Stream::le
  • Stream::lt
  • Stream::map
  • Stream::max
  • Stream::max_by
  • Stream::max_by_key
  • Stream::min
  • Stream::min_by
  • Stream::min_by_key
  • Stream::ne
  • Stream::nth
  • Stream::partial_cmp
  • Stream::partition
  • Stream::peekable -> wip #366
  • Stream::position
  • Stream::product
  • Stream::rev
  • Stream::rposition
  • Stream::scan
  • Stream::size_hint
  • Stream::skip
  • Stream::skip_while
  • Stream::step_by
  • Stream::sum
  • Stream::take
  • Stream::take_while
  • Stream::try_fold
  • Stream::try_for_each
  • Stream::unzip
  • Stream::zip

Missing IntoStream impls

Currently not possible. See #129 (comment)

Missing FromStream impls

  • FromStream<()> for ()
  • FromStream<char> for String
  • FromStream<String> for String
  • FromStream<&'a char> for String
  • FromStream<&'a str> for String
  • FromStream<T> for Cow<'a, [T]> where T: Clone
  • FromStream<A> for Box<[A]>
  • FromStream<A> for VecDeque<A>
  • FromStream<Result<A, E>> for Result<V, E> where V: FromStream<A>
  • FromStream<Option<A>> for Option<V> where V: FromStream<A>
  • FromStream<(K, V)> for BTreeMap<K, V> where K: Ord
  • FromStream<(K, V)> for HashMap<K, V, S> where K: Eq + Hash, S: BuildHasher + Default
  • FromStream<T> for BinaryHeap<T> where T: Ord
  • FromStream<T> for BTreeSet<T> where T: Ord
  • FromStream<T> for LinkedList<T>
  • FromStream<T> for Vec<T>
  • FromStream<T> for HashSet<T, S> where T: Eq + Hash, S: BuildHasher + Default

DoubleEndedStream

  • DoubleEndedStream::poll_next_back
  • DoubleEndedStream::next_back
  • DoubleEndedStream::nth_back
  • DoubleEndedStream::rfind
  • DoubleEndedStream::rfold
  • DoubleEndedStream::try_rfold
@yoshuawuyts yoshuawuyts changed the title [tracking issue] streams [tracking] streams Aug 30, 2019
@vertexclique

This comment has been minimized.

Copy link
Member

@vertexclique vertexclique commented Aug 30, 2019

I've documented some things out here:

https://paper.dropbox.com/doc/async-flow--AjJPPnPNL6eLfTQ3FT3Qew3zAQ-qCeBTk0Z0Nk92kn1ifNbQ

It was open for comments.

@sepiropht

This comment has been minimized.

Copy link

@sepiropht sepiropht commented Aug 30, 2019

I would like to port map, filter and fold :). I like this function in std.

I'm never seriously did any async with rust before. @vertexclique the link you posted is an example we should follow to implement all this functions ?

@shekohex

This comment has been minimized.

Copy link
Contributor

@shekohex shekohex commented Aug 30, 2019

I started with simple methods like any and all here at #132

@sepiropht you may take a look at my pr, and the stream::take() method too.
simply create your struct Map and implement futures::Stream for it, by polling the inner stream and apply the provided function for every item to the stream.

@sepiropht

This comment has been minimized.

Copy link

@sepiropht sepiropht commented Aug 30, 2019

Ok thanks @shekohex. I will try that

@vertexclique

This comment has been minimized.

Copy link
Member

@vertexclique vertexclique commented Aug 30, 2019

@sepiropht from my point of view better to concentrate on FromStream and IntoIter ones are important. Other than that, I suggest following the list of Yoshua for method impls.

@taiki-e

This comment has been minimized.

Copy link
Member

@taiki-e taiki-e commented Aug 31, 2019

Note that some features on this list are not useful until asynchronous closure is improved.

@taiki-e

This comment has been minimized.

Copy link
Member

@taiki-e taiki-e commented Sep 6, 2019

@yoshuawuyts
btw, the following items are unstable.
https://doc.rust-lang.org/nightly/core/iter/trait.Iterator.html#method.is_sorted

  • Stream::is_sorted
  • Stream::is_sorted_by
  • Stream::is_sorted_by_key

https://doc.rust-lang.org/nightly/core/iter/fn.once_with.html

  • once_with
@yoshuawuyts

This comment has been minimized.

Copy link
Member Author

@yoshuawuyts yoshuawuyts commented Sep 6, 2019

@taiki-e thanks, I've updated the issue!

bors bot added a commit that referenced this issue Sep 8, 2019
149: update deps r=stjepang a=yoshuawuyts

Updates all deps. Thanks!

150: split stream into multiple files r=stjepang a=yoshuawuyts

This splits `stream/mod.rs`'s combinators into multiple files, making it easier to contribute combinators. Additionally we've renamed `MinBy` to `MinByFuture` to make it the same as the other private futures. Ref #146 #129. Thanks!

Co-authored-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
Co-authored-by: Stjepan Glavina <stjepang@gmail.com>
bors bot added a commit that referenced this issue Sep 10, 2019
Merge #166
166: adds stream::nth combinator r=yoshuawuyts a=montekki

Implements `nth` combinator.

---
Stdlib: https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.nth
Ref: #129 

Co-authored-by: Fedor Sakharov <fedor.sakharov@gmail.com>
bors bot added a commit that referenced this issue Sep 10, 2019
Merge #163
163: adds stream::filter_map combinator r=yoshuawuyts a=montekki

Implements a `flat_map` combinator. Currently the same about `ret!` as in #162 .

Also the naming should probably be `FilterMapStream`, but in that case `Take` stream should also change it's name i guess.

Stdlib: https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.flat_map
Ref: #129 

Co-authored-by: Fedor Sakharov <fedor.sakharov@gmail.com>
bors bot added a commit that referenced this issue Sep 10, 2019
Merge #174
174: adds stream::find_map combinator r=yoshuawuyts a=montekki

Adds a `stream::find_map` combinator
---
Stdlib: https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.find_map
Ref: #129 

Co-authored-by: Fedor Sakharov <fedor.sakharov@gmail.com>
bors bot added a commit that referenced this issue Sep 10, 2019
Merge #179
179: adds stream::find combinator r=yoshuawuyts a=montekki

A find combinator
---
Stdlib: https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.find
Ref: #129 

Co-authored-by: Fedor Sakharov <fedor.sakharov@gmail.com>
@yoshuawuyts yoshuawuyts referenced this issue Sep 11, 2019
3 of 3 tasks complete
bors bot added a commit that referenced this issue Sep 13, 2019
Merge #177
177: implement DoubleEndedStream r=yoshuawuyts a=yoshuawuyts

Ref #129. This is the most basic version of the `DoubleEndedStream` trait. Because there is no counterpart in `futures-rs` we allow this to be implementable (not sure if we should though?).

This is not a high-priority trait to implement, with probably the most useful addition being the blanket impl over [`std::iter::Fuse`](https://doc.rust-lang.org/std/iter/struct.Fuse.html) (where we should have a `Fuse` counterpart for `Stream` also).

So I'm taking this one step at the time, and this PR introduces just the bare minimum to get things working. Thanks!

r? @stjepang @taiki-e

## Refs
- https://doc.rust-lang.org/std/iter/trait.DoubleEndedIterator.html
- #129 


Co-authored-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
@tirr-c tirr-c referenced this issue Sep 14, 2019
@starsheriff

This comment has been minimized.

Copy link
Contributor

@starsheriff starsheriff commented Oct 15, 2019

I will take a look at peekable next. Hope there is no blocker.

@starsheriff

This comment has been minimized.

Copy link
Contributor

@starsheriff starsheriff commented Oct 15, 2019

Btw. It looks like fold and for_each are already implemented, but not ticked off in the list above.

@felipesere

This comment has been minimized.

Copy link
Contributor

@felipesere felipesere commented Oct 19, 2019

I would like to try the min-max-family.

@ktomsic

This comment has been minimized.

Copy link
Contributor

@ktomsic ktomsic commented Oct 20, 2019

If they're not claimed yet, I'd like to do Stream::sum() and Stream::product().

@stjepang

This comment has been minimized.

Copy link
Member

@stjepang stjepang commented Oct 20, 2019

@ktomsic It's all yours, go ahead :)

This was referenced Oct 23, 2019
This was referenced Oct 23, 2019
This was referenced Oct 31, 2019
@yjhmelody

This comment has been minimized.

Copy link
Contributor

@yjhmelody yjhmelody commented Oct 31, 2019

The Stream::rposition maybe need DoubleEndStream?
I see std's signature

fn rposition<P>(&mut self, predicate: P) -> Option<usize>
where
    P: FnMut(Self::Item) -> bool,
    Self: Sized + ExactSizeIterator + DoubleEndedIterator, 

So are the rev

This was referenced Oct 31, 2019
This was referenced Nov 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
You can’t perform that action at this time.