Skip to content

FromStream impls for collections (and more!) #271

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 13 commits into from
Oct 5, 2019

Conversation

sunjay
Copy link
Contributor

@sunjay sunjay commented Oct 2, 2019

Just opening this to have some visibility on my work as I finish it off. Hopefully will be done in the next day or two, but if not, this is here for someone else to finish it off.

I'm currently in the process of adding the FromStream impls for all the collections. This is generally a very easy and repetitive process:

  1. Look up the impl of FromIterator for the given collection, it probably uses the Extend trait which is also implemented for that collection
  2. Copy and paste the directory for the collection that is closest to the collection you're currently doing (closest in terms of the type parameters needed)
  3. Update the Extend impl to be for the collection you're implementing, being careful to use the reserve method if the collection has one to avoid allocating too many times
  4. Update the FromStream impl to be for the collection you're implementing
  5. Make sure you update the docs in the copied mod.rs and that you've updated collections/mod.rs
  6. Test with --features unstable or your code will not be compiled

The majority of this work is just looking at what std does and adapting it to streams. Honestly it's kind of relaxing after a long day... (maybe I'm weird!) 😄

@sunjay sunjay marked this pull request as ready for review October 3, 2019 01:37
@sunjay sunjay changed the title [WIP] FromStream impls for collections (and more!) FromStream impls for collections (and more!) Oct 3, 2019
@sunjay
Copy link
Contributor Author

sunjay commented Oct 3, 2019

@yoshuawuyts This PR is ready for review/merge! You should merge #266 first. Once that and this PR are merged, you can check off all the impls for FromStream in #129. We did it! 🎉

I believe we actually cover even more than what's listed in the original tracking issue. I intentionally went off of the FromIterator documentation and implemented pretty much all of what's there. There's some impls on references that haven't been added yet, but I think everything here is very usable as is! 🎉 😄

@sunjay sunjay mentioned this pull request Oct 3, 2019
87 tasks
@yoshuawuyts
Copy link
Contributor

@sunjay thanks so much for this! -- could you perhaps rebase on master to get the clippy fixes in for CI? Thanks!

@sunjay
Copy link
Contributor Author

sunjay commented Oct 4, 2019

It's rebased!

@yoshuawuyts
Copy link
Contributor

All tests are passing; this is really good!! Let's merge this!

bors r+

bors bot added a commit that referenced this pull request Oct 5, 2019
271: FromStream impls for collections (and more!) r=yoshuawuyts a=sunjay

Just opening this to have some visibility on my work as I finish it off. Hopefully will be done in the next day or two, but if not, this is here for someone else to finish it off.

I'm currently in the process of adding the `FromStream` impls for all the collections. This is generally a very easy and repetitive process:

1. Look up the impl of `FromIterator` for the given collection, it probably uses the `Extend` trait which is also implemented for that collection
2. Copy and paste the directory for the collection that is closest to the collection you're currently doing (closest in terms of the type parameters needed)
3. Update the `Extend` impl to be for the collection you're implementing, being careful to use the `reserve` method if the collection has one to avoid allocating too many times
4. Update the `FromStream` impl to be for the collection you're implementing
5. Make sure you update the docs in the copied `mod.rs` and that you've updated `collections/mod.rs`
6. Test with `--features unstable` or your code will not be compiled

The majority of this work is just looking at what `std` does and adapting it to streams. Honestly it's kind of relaxing after a long day... (maybe I'm weird!) 😄

Co-authored-by: Sunjay Varma <[email protected]>
@bors
Copy link
Contributor

bors bot commented Oct 5, 2019

Build succeeded

  • continuous-integration/travis-ci/push

@bors bors bot merged commit f968c9a into async-rs:master Oct 5, 2019
@sunjay sunjay deleted the fromstream-impls branch October 5, 2019 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants