Skip to content

Commit 8e3416d

Browse files
authored
Merge pull request #244 from tmandry/random-footnotes
random footnotes
2 parents 0dbce14 + 143d85e commit 8e3416d

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

src/vision/roadmap/async_fn/boxable.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,25 @@ async fn foo() { }
2727
```
2828

2929
This does not have to desugar to `-> Box<dyn Future<...>>`; it can instead desugar to `Box<impl Future>`, or perhaps a nominal type to permit recursion.
30+
31+
Another approach is the `box` keyword:
32+
33+
```rust
34+
box async fn foo() { }
35+
```
36+
37+
We can apply the keyword modifier to async blocks and closures:
38+
39+
```rust
40+
fn foo() -> BoxFuture<Output = ()> {
41+
box async { ... }
42+
}
43+
```
44+
45+
```rust
46+
async fn stuff(s: impl AsyncIterator) {
47+
s.map(box async |x| { ... })
48+
}
49+
```
50+
51+
This is useful for breaking up future types to make them more shallow.

src/vision/roadmap/portable/read_write.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ trait AsyncWrite {
2727

2828
This form doesn't permit one to simultaneously be reading and writing. Moreover, SSL requires changing modes, so that e.g. performing a read may require writing to the underlying socket, and vice versa. (Link?)
2929

30+
Note also that using `std::io::Result` would make the traits unusable in `#[no_std]` (this is also the case with the regular `Read` and `Write` traits), which might preclude embedded uses of these traits. These fundamental traits could all be added to `alloc` (but not `core`, because `std::io::Error` depends on `Box`).
31+
3032
### Variant A: Readiness
3133

3234
One possibility is the design that [CarlLerche proposed](https://gist.github.com/carllerche/5d7037bd55dac1cb72891529a4ff1540), which separates "readiness" from the actual (non-async) methods to acquire the data:

0 commit comments

Comments
 (0)