@@ -71,6 +71,7 @@ new syntax:
71
71
[ hyper#1805 ] : https://github.com/hyperium/hyper/issues/1805
72
72
[ async-std ] : https://async.rs/
73
73
[ wf ] : https://www.arewewebyet.org/topics/frameworks/
74
+ [ JavaScript promises ] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Using_promises
74
75
75
76
### Async-await: a quick primer
76
77
@@ -82,9 +83,8 @@ can "pause", return control to the runtime, and then pick up from
82
83
where they left off. Typically those pauses are to wait for I/O, but
83
84
there can be any number of uses.
84
85
85
- You may be familiar with the async-await from other languages, such as
86
- JavaScript or C#. Rust's version of the feature is similar, but with a
87
- few key differences.
86
+ You may be familiar with the async-await from JavaScript or C#. Rust's
87
+ version of the feature is similar, but with a few key differences.
88
88
89
89
To use async-await, you start by writing ` async fn ` instead of ` fn ` :
90
90
@@ -118,12 +118,12 @@ errors. It also has the advantage of making method chaining painless.
118
118
119
119
### Zero-cost futures
120
120
121
- The other difference between Rust futures and futures in other
122
- languages is that they are based on a "poll" model, which makes them
123
- ** zero cost** . In other languages, invoking an async function
124
- immediately creates a future and schedules it for execution: awaiting
125
- the future isn't necessary for it to execute. But this implies some
126
- overhead for each future that is created.
121
+ The other difference between Rust futures and futures in JS and C# is
122
+ that they are based on a "poll" model, which makes them ** zero
123
+ cost** . In other languages, invoking an async function immediately
124
+ creates a future and schedules it for execution: awaiting the future
125
+ isn't necessary for it to execute. But this implies some overhead for
126
+ each future that is created.
127
127
128
128
In contrast, in Rust, calling an async function does not do any
129
129
scheduling in and of itself, which means that we can compose a complex
0 commit comments