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
84 of 87 tasks
yoshuawuyts opened this issue Aug 30, 2019 · 29 comments
Open
84 of 87 tasks

[tracking] streams #129

yoshuawuyts opened this issue Aug 30, 2019 · 29 comments
Labels
enhancement New feature or request
Milestone

Comments

@yoshuawuyts
Copy link
Contributor

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
  • 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 add stream::peekable #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 added the enhancement New feature or request label Aug 30, 2019
@yoshuawuyts yoshuawuyts changed the title [tracking issue] streams [tracking] streams Aug 30, 2019
@vertexclique
Copy link
Member

I've documented some things out here:

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

It was open for comments.

@sepiropht
Copy link

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
Copy link
Contributor

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
Copy link

Ok thanks @shekohex. I will try that

@vertexclique
Copy link
Member

@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
Copy link
Contributor

taiki-e commented Aug 31, 2019

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

@taiki-e
Copy link
Contributor

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
Copy link
Contributor Author

@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
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
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
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
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 mentioned this issue Sep 11, 2019
3 tasks
bors bot added a commit that referenced this issue Sep 13, 2019
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>
@felipesere
Copy link
Contributor

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

@ktomsic
Copy link
Contributor

ktomsic commented Oct 20, 2019

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

@ghost
Copy link

ghost 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
Copy link
Contributor

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
@felipesere
Copy link
Contributor

I've started to play with the Double ended iterators

@felipesere
Copy link
Contributor

@yoshuawuyts I think we can cross of a bunch of things here, unless it only considers stable features?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

10 participants