Skip to content

Commit 75552dd

Browse files
authored
Merge pull request #240 from tmandry/redirect-fundamentals
Move async fundamentals out of this repo
2 parents e296ab0 + 699da89 commit 75552dd

24 files changed

+19
-636
lines changed

src/SUMMARY.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,6 @@
2828
- [📚 User's manual of the future](./vision/shiny_future/users_manual.md)
2929
- [📅 Roadmap](./vision/roadmap.md)
3030
- [Async fn everywhere](./vision/roadmap/async_fn.md)
31-
- [Async fn fundamentals](./vision/roadmap/async_fn/async_fn_fundamentals.md)
32-
- [Static async trait](./vision/roadmap/async_fn/async_fn_fundamentals/static_async_trait.md)
33-
- [impl Trait in traits](./vision/roadmap/async_fn/async_fn_fundamentals/impl_trait_in_traits.md)
34-
- [Dyn async trait](./vision/roadmap/async_fn/async_fn_fundamentals/dyn_async_trait.md)
35-
- [Dyn trait](./vision/roadmap/async_fn/async_fn_fundamentals/dyn_trait.md)
36-
- [Async drop](./vision/roadmap/async_fn/async_fn_fundamentals/async_drop.md)
37-
- [Async closures](./vision/roadmap/async_fn/async_fn_fundamentals/async_closures.md)
3831
- [Boxable async fn](./vision/roadmap/async_fn/boxable.md)
3932
- [Async main and tests](./vision/roadmap/async_fn/async_main_and_tests.md)
4033
- [Scoped spawn and reliable cancellation](./vision/roadmap/scopes.md)

src/design_docs/async_drop.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
# 🗑️ Async drop
1+
# 🗑️ Async drop
Lines changed: 0 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,88 +1 @@
11
# 🧬 Async fn in traits
2-
3-
* [Why async fn in traits are hard][wafth]
4-
5-
[wafth]: http://smallcultfollowing.com/babysteps/blog/2019/10/26/async-fn-in-traits-are-hard/
6-
7-
## General goal
8-
9-
```rust,ignore
10-
trait Foo {
11-
// Currently disallowed:
12-
async fn bar();
13-
}
14-
```
15-
16-
## Concerns
17-
18-
### How to name the resulting future
19-
20-
If you wanted to name the future that results from calling `bar` (or whatever), you can't.
21-
22-
Also true for functions `fn bar() -> impl Trait`.
23-
24-
### Requiring `Send` on futures
25-
26-
[Relevant thread](https://internals.rust-lang.org/t/how-often-do-you-want-non-send-futures/10360)
27-
28-
```rust,ignore
29-
async fn foo() {}
30-
31-
// desugars to
32-
fn foo() -> impl Future<Output = ()> { } // resulting type is Send if it can be
33-
34-
// alternative desugaring we chose not to adopt would require Send
35-
fn foo() -> impl Future + Send { }
36-
```
37-
38-
If I want to constrain the future I get back from a method, it is difficult to do without a name:
39-
40-
```rust,ignore
41-
trait Service {
42-
async fn request(&self);
43-
}
44-
45-
fn parallel_service<S: Service>()
46-
where
47-
S::Future: Send,
48-
{
49-
...
50-
}
51-
```
52-
53-
* Should this be solved at the impl trait layer
54-
* Or should we specialize something for async functions
55-
* Would be nice, if there are many, associated types, to have some shorthand
56-
57-
## Example use case: the Service
58-
59-
```rust,ignore
60-
trait Service {
61-
type Future: Future<Output = Response>;
62-
63-
fn request(&self, ...) -> Self::Future;
64-
}
65-
66-
impl Service for MyService {
67-
type Future = impl Future<Output = Response>;
68-
69-
fn request(&self) -> Self::Future {
70-
async move { .. }
71-
}
72-
}
73-
```
74-
75-
* Dependent on impl Trait, see lang-team repo
76-
77-
## Example use case: capturing lifetimes of arguments
78-
79-
```rust,ignore
80-
trait MyMethod {
81-
async fn foo(&self);
82-
}
83-
```
84-
85-
## 🤔 Frequently Asked Questions
86-
87-
### **What do people say about this to their friends on twitter?**
88-
* (Explain your key points here)

src/design_docs/async_main.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1 @@
11
# 🎇 Async main
2-
3-
## What is it?
4-
5-
## Motivation
6-
7-
## Frequently Asked Questions
Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
11
# ⏳ Completion-based futures
2-
3-
[Notes on io_uring][withoutboats-blog]
4-
5-
[withoutboats-blog]: https://boats.gitlab.io/blog/post/io-uring
Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1 @@
1-
# ⚡ Generator syntax
2-
3-
* It would be useful to be able to write a function to return an iterator or (in the async context) a generator
4-
* The basic shape might be (modulo bikeshedding) `gen fn` that contains `yield`
5-
* Some question marks:
6-
* How general of a mechanism do we want?
7-
* Just target iterators and streams, or shoot for something more general?
8-
* Some of the question marks that arise if you go beyond iterators and streams:
9-
* Return values that are not unit
10-
* Have yield return a value that is passed by the caller of `next` ("resume args")
1+
# ⚡ Generator syntax

src/design_docs/mutex.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1 @@
11
# 🔒 Mutex (future-aware)
2-
3-
[Description of various challenges with async mutexes][blog]
4-
5-
[blog]: https://github.com/Diggsey/posts/tree/master/async-mutexes
6-
7-

src/design_docs/stream.md

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1 @@
11
# ☔ Stream trait
2-
3-
* [Current definition](https://docs.rs/futures/0.3/futures/stream/trait.Stream.html)
4-
5-
## Trait definition
6-
7-
```rust,ignore
8-
pub trait Stream {
9-
type Item;
10-
11-
fn poll_next(
12-
self: Pin<&mut Self>,
13-
cx: &mut Context<'_>,
14-
) -> Poll<Option<Self::Item>>;
15-
16-
#[inline]
17-
fn size_hint(&self) -> (usize, Option<usize>) {
18-
(0, None)
19-
}
20-
}
21-
```
22-
23-
## Concerns
24-
25-
### Poll-based design
26-
27-
* You have to think about Pin if you implement this trait.
28-
* Combinators can be more difficult.
29-
* One solution: [generator syntax](./generator_syntax.md).
30-
31-
### Attached streams are commonly desired
32-
33-
Sometimes streams need to reuse internal storage ([Discussion]).
34-
35-
[Discussion]: http://smallcultfollowing.com/babysteps/blog/2019/12/10/async-interview-2-cramertj-part-2/#the-need-for-streaming-streams-and-iterators
36-
37-
### Combinators
38-
39-
* Currently the combinations are stored in the [`StreamExt`] module.
40-
* In some cases, this is because of the lack of async closures support.
41-
* Also serves as a "semver barrier".
42-
* Also no-std compatibility.
43-
* One question: what combinators (if any) to include when stabilizing?
44-
* e.g., [`poll_next_unpin`] can make working with pin easier, albeit at a loss of generality
45-
* folks who are new to pinning could use this method, and it can help us to guide the diagnostics by suggesting that they `Box::pin`
46-
47-
[`StreamExt`]: https://docs.rs/futures/0.3/futures/stream/trait.StreamExt.html
48-
[`poll_next_unpin`]: https://docs.rs/futures/0.3/futures/stream/trait.StreamExt.html#method.poll_next_unpin

src/design_docs/yield_safe.md

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1 @@
11
# ⚠️ Yield-safe lint
2-
3-
## Use-case
4-
5-
Some types should not be held across a "yield" bound. A typical example is a `MutexGuard`:
6-
7-
```rust,ignore
8-
async fn example(x: &Lock<u32>) {
9-
let data = x.lock().unwrap();
10-
something().await;
11-
*data += 1;
12-
}
13-
14-
async fn something() { }
15-
```
16-
17-
In practice, a lot of these issues are avoided because `MutexGuard` is not `Send`, but single-thread runtimes hit these issues.
18-
19-
## Types where this would apply
20-
21-
* `MutexGuard` for mutexes, read-write locks
22-
* Guards for ref-cells
23-
* Things that might use these types internally and wish to bubble it up
24-
25-
## Precedent and related questions
26-
27-
* The `#[must_use]` lint on types, we would want their design to work very closely.
28-
* Non-async-friendly functions like `sleep` or `task::block_on`.

src/vision/roadmap.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ Clicking on active initiatives also shows a list of *milestones*. These mileston
6161
| &nbsp;&nbsp;↳ tbd | 💤 | ▰▱▱▱▱▱ |
6262

6363
[Async fn everywhere]: ./roadmap/async_fn.md
64-
[fundamentals]: ./roadmap/async_fn/async_fn_fundamentals.md
65-
[Async closures]: ./roadmap/async_fn/async_fn_fundamentals/async_closures.md
64+
[fundamentals]: https://rust-lang.github.io/async-fundamentals-initiative/
65+
[Async closures]: https://rust-lang.github.io/async-fundamentals-initiative/design-discussions/async_closures.html
6666
[Boxable async functions]: ./roadmap/async_fn/boxable.md
6767
[Async main and tests]: ./roadmap/async_fn/async_main_and_tests.md
6868
[Scoped spawn and reliable cancellation]: ./roadmap/scopes.md

0 commit comments

Comments
 (0)