passing tests on latest nightly

This commit is contained in:
Carl Fredrik Samson
2020-02-25 19:02:19 +01:00
parent 15936dc004
commit aacb3683a0
11 changed files with 14 additions and 157 deletions

View File

@@ -203,7 +203,7 @@ executor.</p>
<p>The bulk of an async program will consist of non-leaf-futures, which are a kind <p>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 <em>set of operations</em>. Often, such a task will <code>await</code> a leaf future of pause-able computation. This is an important distinction since these futures represents a <em>set of operations</em>. Often, such a task will <code>await</code> a leaf future
as one of many operations to complete the task.</p> as one of many operations to complete the task.</p>
<pre><code class="language-rust ignore noplaypen">// Non-leaf-future <pre><code class="language-rust ignore noplaypen edition2018">// Non-leaf-future
let non_leaf = async { let non_leaf = async {
let mut stream = TcpStream::connect(&quot;127.0.0.1:3000&quot;).await.unwrap();// &lt;- yield let mut stream = TcpStream::connect(&quot;127.0.0.1:3000&quot;).await.unwrap();// &lt;- yield
println!(&quot;connected!&quot;); println!(&quot;connected!&quot;);
@@ -312,21 +312,6 @@ it needs to be, so go on and read these chapters if you feel a bit unsure. </p>
</div> </div>
<!-- Livereload script (if served using the cli tool) -->
<script type="text/javascript">
var socket = new WebSocket("ws://localhost:3001");
socket.onmessage = function (event) {
if (event.data === "reload") {
socket.close();
location.reload(true); // force reload from server (not from cache)
}
};
window.onbeforeunload = function() {
socket.close();
}
</script>
<!-- Google Analytics Tag --> <!-- Google Analytics Tag -->

View File

@@ -348,21 +348,6 @@ use purely global functions and state, or any other way you wish.</p>
</div> </div>
<!-- Livereload script (if served using the cli tool) -->
<script type="text/javascript">
var socket = new WebSocket("ws://localhost:3001");
socket.onmessage = function (event) {
if (event.data === "reload") {
socket.close();
location.reload(true); // force reload from server (not from cache)
}
};
window.onbeforeunload = function() {
socket.close();
}
</script>
<!-- Google Analytics Tag --> <!-- Google Analytics Tag -->

View File

@@ -699,21 +699,6 @@ pub fn main() {
</div> </div>
<!-- Livereload script (if served using the cli tool) -->
<script type="text/javascript">
var socket = new WebSocket("ws://localhost:3001");
socket.onmessage = function (event) {
if (event.data === "reload") {
socket.close();
location.reload(true); // force reload from server (not from cache)
}
};
window.onbeforeunload = function() {
socket.close();
}
</script>
<!-- Google Analytics Tag --> <!-- Google Analytics Tag -->

View File

@@ -470,21 +470,6 @@ we're soon finished.</p>
</div> </div>
<!-- Livereload script (if served using the cli tool) -->
<script type="text/javascript">
var socket = new WebSocket("ws://localhost:3001");
socket.onmessage = function (event) {
if (event.data === "reload") {
socket.close();
location.reload(true); // force reload from server (not from cache)
}
};
window.onbeforeunload = function() {
socket.close();
}
</script>
<!-- Google Analytics Tag --> <!-- Google Analytics Tag -->

View File

@@ -1043,21 +1043,6 @@ exploration will get a lot easier. </p>
</div> </div>
<!-- Livereload script (if served using the cli tool) -->
<script type="text/javascript">
var socket = new WebSocket("ws://localhost:3001");
socket.onmessage = function (event) {
if (event.data === "reload") {
socket.close();
location.reload(true); // force reload from server (not from cache)
}
};
window.onbeforeunload = function() {
socket.close();
}
</script>
<!-- Google Analytics Tag --> <!-- Google Analytics Tag -->

View File

@@ -392,21 +392,6 @@ impl Drop for Reactor {
</div> </div>
<!-- Livereload script (if served using the cli tool) -->
<script type="text/javascript">
var socket = new WebSocket("ws://localhost:3001");
socket.onmessage = function (event) {
if (event.data === "reload") {
socket.close();
location.reload(true); // force reload from server (not from cache)
}
};
window.onbeforeunload = function() {
socket.close();
}
</script>
<!-- Google Analytics Tag --> <!-- Google Analytics Tag -->

View File

@@ -254,21 +254,6 @@ articles I've already linked to in the book, here are some of my suggestions:</p
</div> </div>
<!-- Livereload script (if served using the cli tool) -->
<script type="text/javascript">
var socket = new WebSocket("ws://localhost:3001");
socket.onmessage = function (event) {
if (event.data === "reload") {
socket.close();
location.reload(true); // force reload from server (not from cache)
}
};
window.onbeforeunload = function() {
socket.close();
}
</script>
<!-- Google Analytics Tag --> <!-- Google Analytics Tag -->

View File

@@ -212,21 +212,6 @@ very well written and very helpful. So thanks!</p>
</div> </div>
<!-- Livereload script (if served using the cli tool) -->
<script type="text/javascript">
var socket = new WebSocket("ws://localhost:3001");
socket.onmessage = function (event) {
if (event.data === "reload") {
socket.close();
location.reload(true); // force reload from server (not from cache)
}
};
window.onbeforeunload = function() {
socket.close();
}
</script>
<!-- Google Analytics Tag --> <!-- Google Analytics Tag -->

View File

@@ -220,21 +220,6 @@ very well written and very helpful. So thanks!</p>
</div> </div>
<!-- Livereload script (if served using the cli tool) -->
<script type="text/javascript">
var socket = new WebSocket("ws://localhost:3001");
socket.onmessage = function (event) {
if (event.data === "reload") {
socket.close();
location.reload(true); // force reload from server (not from cache)
}
};
window.onbeforeunload = function() {
socket.close();
}
</script>
<!-- Google Analytics Tag --> <!-- Google Analytics Tag -->

View File

@@ -245,7 +245,7 @@ executor.</p>
<p>The bulk of an async program will consist of non-leaf-futures, which are a kind <p>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 <em>set of operations</em>. Often, such a task will <code>await</code> a leaf future of pause-able computation. This is an important distinction since these futures represents a <em>set of operations</em>. Often, such a task will <code>await</code> a leaf future
as one of many operations to complete the task.</p> as one of many operations to complete the task.</p>
<pre><code class="language-rust ignore noplaypen">// Non-leaf-future <pre><code class="language-rust ignore noplaypen edition2018">// Non-leaf-future
let non_leaf = async { let non_leaf = async {
let mut stream = TcpStream::connect(&quot;127.0.0.1:3000&quot;).await.unwrap();// &lt;- yield let mut stream = TcpStream::connect(&quot;127.0.0.1:3000&quot;).await.unwrap();// &lt;- yield
println!(&quot;connected!&quot;); println!(&quot;connected!&quot;);
@@ -2424,21 +2424,6 @@ articles I've already linked to in the book, here are some of my suggestions:</p
</div> </div>
<!-- Livereload script (if served using the cli tool) -->
<script type="text/javascript">
var socket = new WebSocket("ws://localhost:3001");
socket.onmessage = function (event) {
if (event.data === "reload") {
socket.close();
location.reload(true); // force reload from server (not from cache)
}
};
window.onbeforeunload = function() {
socket.close();
}
</script>
<!-- Google Analytics Tag --> <!-- Google Analytics Tag -->

View File

@@ -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 example in Rust today using the `static` keyword on nightly. Try it for
yourself: 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 ```rust
#![feature(generators, generator_trait)] #![feature(generators, generator_trait)]
use std::ops::{Generator, GeneratorState}; use std::ops::{Generator, GeneratorState};
@@ -541,16 +547,16 @@ pub fn main() {
let mut pinned1 = Box::pin(gen1); let mut pinned1 = Box::pin(gen1);
let mut pinned2 = Box::pin(gen2); 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); 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); println!("Gen2 got value {}", n);
}; };
let _ = pinned1.as_mut().resume(); let _ = pinned1.as_mut().resume(());
let _ = pinned2.as_mut().resume(); let _ = pinned2.as_mut().resume(());
} }
``` ```
@@ -559,4 +565,5 @@ pub fn main() {
[rfc1823]: https://github.com/rust-lang/rfcs/pull/1823 [rfc1823]: https://github.com/rust-lang/rfcs/pull/1823
[rfc1832]: https://github.com/rust-lang/rfcs/pull/1832 [rfc1832]: https://github.com/rust-lang/rfcs/pull/1832
[optimizing-await]: https://tmandry.gitlab.io/blog/posts/optimizing-await-1/ [optimizing-await]: https://tmandry.gitlab.io/blog/posts/optimizing-await-1/
[pr45337]: https://github.com/rust-lang/rust/pull/45337/files [pr45337]: https://github.com/rust-lang/rust/pull/45337/files
[issue43122]: https://github.com/rust-lang/rust/issues/43122