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
Prev Previous commit
Next Next commit
some corrections
Signed-off-by: Nell Shamrell <[email protected]>
nellshamrell committed Jun 4, 2020
commit a2b814038c2520d49299777c0af56d66d3514fa3
12 changes: 2 additions & 10 deletions rfc-drafts/stream.md
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@

Introduce the `Stream` trait into the standard library, using the
design from `futures`. Redirect the `Stream` trait definition in the
`futures` crate to the standard library.
`futures-core` crate (which is "pub-used" by the `futures` crate) to the standard library.

# Motivation
[motivation]: #motivation
@@ -252,7 +252,7 @@ We may wish to extend the `for` loop so that it works over streams as well.
for elem in stream { ... }
```

Designing this extension is out of scope for this RFC.
Designing this extension is out of scope for this RFC. However, it could be prototyped using procedural macros today.

## "Attached" streams

@@ -266,14 +266,6 @@ In a **detached** stream, the `Item` that gets returned by `Stream` is "detached

In an **attached** stream, the `Item` that gets returned by `Stream` may be borrowed from `self`. It can only be used as long as the `self` reference remains live.

### Alternate terminology

An alternative terminology - which may be easier to understand in terms of ownership and borrowed - involves **owned** and **borrowed** streams.

An **owned** stream is like a **detached** stream. The `Stream` transfers ownership of the `Item` returned by it to you.

A **borrowed** stream is like an **attached** stream. The `Item` you get back from the `Stream` is borrowed from the `Stream` itself.

This RFC does not cover the addition of attached/detached owned/borrowed streams.
We can add the `Stream` trait to the standard library now and delay
adding in this distinction between two types of streams. The advantage of this