From aacb3683a06711da59a6fdb5b8b831147966193e Mon Sep 17 00:00:00 2001
From: Carl Fredrik Samson
The bulk of an async program will consist of non-leaf-futures, which are a kind
of pause-able computation. This is an important distinction since these futures represents a set of operations. Often, such a task will await a leaf future
as one of many operations to complete the task.
// Non-leaf-future
+// Non-leaf-future
let non_leaf = async {
let mut stream = TcpStream::connect("127.0.0.1:3000").await.unwrap();// <- yield
println!("connected!");
@@ -312,21 +312,6 @@ it needs to be, so go on and read these chapters if you feel a bit unsure.
-
-
-
diff --git a/book/2_waker_context.html b/book/2_waker_context.html
index 3aed484..29677c8 100644
--- a/book/2_waker_context.html
+++ b/book/2_waker_context.html
@@ -348,21 +348,6 @@ use purely global functions and state, or any other way you wish.
-
-
-
diff --git a/book/3_generators_pin.html b/book/3_generators_pin.html
index 78c3299..93ebdd8 100644
--- a/book/3_generators_pin.html
+++ b/book/3_generators_pin.html
@@ -699,21 +699,6 @@ pub fn main() {
-
-
-
diff --git a/book/4_pin.html b/book/4_pin.html
index 4a1b27c..dbe6ba5 100644
--- a/book/4_pin.html
+++ b/book/4_pin.html
@@ -470,21 +470,6 @@ we're soon finished.
-
-
-
diff --git a/book/6_future_example.html b/book/6_future_example.html
index 0fdde56..8dca0bf 100644
--- a/book/6_future_example.html
+++ b/book/6_future_example.html
@@ -1043,21 +1043,6 @@ exploration will get a lot easier.
-
-
-
diff --git a/book/8_finished_example.html b/book/8_finished_example.html
index 9712cf1..ee9269d 100644
--- a/book/8_finished_example.html
+++ b/book/8_finished_example.html
@@ -392,21 +392,6 @@ impl Drop for Reactor {
-
-
-
diff --git a/book/conclusion.html b/book/conclusion.html
index 5657576..1607110 100644
--- a/book/conclusion.html
+++ b/book/conclusion.html
@@ -254,21 +254,6 @@ articles I've already linked to in the book, here are some of my suggestions:
-
-
-
diff --git a/book/index.html b/book/index.html
index 4d0a743..69414d1 100644
--- a/book/index.html
+++ b/book/index.html
@@ -212,21 +212,6 @@ very well written and very helpful. So thanks!
-
-
-
diff --git a/book/introduction.html b/book/introduction.html
index 7d29c30..755b073 100644
--- a/book/introduction.html
+++ b/book/introduction.html
@@ -220,21 +220,6 @@ very well written and very helpful. So thanks!
-
-
-
diff --git a/book/print.html b/book/print.html
index 884a279..4d4fad9 100644
--- a/book/print.html
+++ b/book/print.html
@@ -245,7 +245,7 @@ executor.
The bulk of an async program will consist of non-leaf-futures, which are a kind
of pause-able computation. This is an important distinction since these futures represents a set of operations. Often, such a task will await a leaf future
as one of many operations to complete the task.
-// Non-leaf-future
+// Non-leaf-future
let non_leaf = async {
let mut stream = TcpStream::connect("127.0.0.1:3000").await.unwrap();// <- yield
println!("connected!");
@@ -2424,21 +2424,6 @@ articles I've already linked to in the book, here are some of my suggestions:
-
-
-
diff --git a/src/3_generators_pin.md b/src/3_generators_pin.md
index de9cb53..07f3641 100644
--- a/src/3_generators_pin.md
+++ b/src/3_generators_pin.md
@@ -518,6 +518,12 @@ Thanks to [PR#45337][pr45337] you can actually run code like the one in our
example in Rust today using the `static` keyword on nightly. Try it for
yourself:
+ Beware that the API is changing rapidly. As I was writing this book
+ Generators had an API change adding support for a "resume" argument to
+ be passed into the generator closure.
+
+ Follow the progress on the [tracking issue #43122][issue43122] for [RFC#2033][rfc2033].
+
```rust
#![feature(generators, generator_trait)]
use std::ops::{Generator, GeneratorState};
@@ -541,16 +547,16 @@ pub fn main() {
let mut pinned1 = Box::pin(gen1);
let mut pinned2 = Box::pin(gen2);
- if let GeneratorState::Yielded(n) = pinned1.as_mut().resume() {
+ if let GeneratorState::Yielded(n) = pinned1.as_mut().resume(()) {
println!("Gen1 got value {}", n);
}
- if let GeneratorState::Yielded(n) = pinned2.as_mut().resume() {
+ if let GeneratorState::Yielded(n) = pinned2.as_mut().resume(()) {
println!("Gen2 got value {}", n);
};
- let _ = pinned1.as_mut().resume();
- let _ = pinned2.as_mut().resume();
+ let _ = pinned1.as_mut().resume(());
+ let _ = pinned2.as_mut().resume(());
}
```
@@ -559,4 +565,5 @@ pub fn main() {
[rfc1823]: https://github.com/rust-lang/rfcs/pull/1823
[rfc1832]: https://github.com/rust-lang/rfcs/pull/1832
[optimizing-await]: https://tmandry.gitlab.io/blog/posts/optimizing-await-1/
-[pr45337]: https://github.com/rust-lang/rust/pull/45337/files
\ No newline at end of file
+[pr45337]: https://github.com/rust-lang/rust/pull/45337/files
+[issue43122]: https://github.com/rust-lang/rust/issues/43122
\ No newline at end of file