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

[DRAFT] Update stream rfc #13

Merged
merged 10 commits into from
Jun 5, 2020

Conversation

nellshamrell
Copy link
Contributor

@nellshamrell nellshamrell commented Jun 3, 2020

This is still a WIP.

Rendered

Signed-off-by: Nell Shamrell <nellshamrell@gmail.com>
Signed-off-by: Nell Shamrell <nellshamrell@gmail.com>
Signed-off-by: Nell Shamrell <nellshamrell@gmail.com>
Signed-off-by: Nell Shamrell <nellshamrell@gmail.com>
Copy link
Contributor

@nikomatsakis nikomatsakis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some brief comments

rfc-drafts/stream.md Outdated Show resolved Hide resolved
rfc-drafts/stream.md Outdated Show resolved Hide resolved

## "Attached" streams

There has been much discussion around attached/detached streams.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should find a time to sketch out what an attached trait would likely look like and some of the possible ways that we might 'interoperate' between them (i.e., every "Detached" steam can become an attached one, and some detached streams can become attached ones, but that is harder to specify), and perhaps to discuss the consideration that

  • the current trait captures the case where the stream gives up ownership, which offers flexibility -- such as the ability to spawn off futures processing each item in parallel
  • an attached trait would capture cases where we are re-using internal buffers, which is less flexible for consumers but potentially more efficient

i.e., there is room for both. And of course we will have to pursue the same design for iterators, whether it be two traits, or one new trait with a "conversion" from the old trait.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

every "Detached" steam can become an attached one, and some detached streams can become attached ones, but that is harder to specify

I'm not quite sure I follow – I think you meant that some attached streams can become detached streams? In that case it seems clear that you would define it as impl Stream from the start, since that's more general?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(We had a more detailed conversation about this on Zulip the other day, follow up there?)

rfc-drafts/stream.md Outdated Show resolved Hide resolved
Signed-off-by: Nell Shamrell <nellshamrell@gmail.com>
…ion of the RFC

Signed-off-by: Nell Shamrell <nellshamrell@gmail.com>
@nellshamrell
Copy link
Contributor Author

@nikomatsakis thank you for the comments - I believe I have addressed all of them.

I also believe the Generator syntax section should be expanded. I would love some ideas of what to focus on.

Signed-off-by: Nell Shamrell <nellshamrell@gmail.com>
Signed-off-by: Nell Shamrell <nellshamrell@gmail.com>
Copy link
Contributor

@nikomatsakis nikomatsakis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few more nit ideas -- happy to land and pursue them as follow-ups -- should we open a tracking issue, @nellshamrell ?

## IntoStream / FromStream traits, mirroring iterators
## IntoStream / FromStream traits

The `IntoStream` trait would provide a way to convert something into a `Stream`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably good to elaborate a bit here and to mention that: Iterators have an IntoIterator trait that is used with for loops. We might want such a trait for streams, and it would look like ...


The `FromStream` trait would provide a way to convert a `Stream` into something else.

Implementing the `IntoStream` and `FromStream` traits on `Stream` is currently blocked on needing [`async fn` available in traits]( http://smallcultfollowing.com/babysteps/blog/2019/10/26/async-fn-in-traits-are-hard).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...that would then clarify why this is true (in fact, I'm not entirely convinced this is true)

rfc-drafts/stream.md Outdated Show resolved Hide resolved
rfc-drafts/stream.md Outdated Show resolved Hide resolved
@nikomatsakis
Copy link
Contributor

Oh, I guess there is a tracking issue. cc #12, maybe you want to add some of the points and to-do items in there...

@nikomatsakis nikomatsakis marked this pull request as ready for review June 5, 2020 20:06
Signed-off-by: Nell Shamrell <nellshamrell@gmail.com>
Signed-off-by: Nell Shamrell <nellshamrell@gmail.com>
@nellshamrell nellshamrell mentioned this pull request Jun 5, 2020
@nellshamrell
Copy link
Contributor Author

Thank you @nikomatsakis! I've incorporated several of those suggestions and placed everything else in a checklist in #12.

Merging.

@nellshamrell nellshamrell merged commit a89f06a into rust-lang:master Jun 5, 2020
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.

None yet

3 participants