making tests pass on windows
This commit is contained in:
@@ -314,7 +314,7 @@ in that book. The code below is wildly unsafe and it's just to show a real examp
|
||||
It's not in any way meant to showcase "best practice". Just so we're on
|
||||
the same page.</p>
|
||||
</blockquote>
|
||||
<pre><pre class="playpen"><code class="language-rust">#![feature(asm)]
|
||||
<pre><pre class="playpen"><code class="language-rust edition2018">#![feature(asm)]
|
||||
#![feature(naked_functions)]
|
||||
use std::ptr;
|
||||
|
||||
@@ -506,7 +506,7 @@ unsafe fn switch(old: *mut ThreadContext, new: *const ThreadContext) {
|
||||
: "alignstack"
|
||||
);
|
||||
}
|
||||
|
||||
# #[cfg(not(windows))]
|
||||
fn main() {
|
||||
let mut runtime = Runtime::new();
|
||||
runtime.init();
|
||||
@@ -523,7 +523,8 @@ fn main() {
|
||||
});
|
||||
runtime.run();
|
||||
}
|
||||
|
||||
# #[cfg(windows)]
|
||||
# fn main() { }
|
||||
</code></pre></pre>
|
||||
<p>Still hanging in there? Good. Don't get frustrated if the code above is
|
||||
difficult to understand. If I hadn't written it myself I would probably feel
|
||||
@@ -669,7 +670,7 @@ a state machine which can be in one of three states: <code>pending</code>, <code
|
||||
promise in the state <code>pending</code>.</p>
|
||||
<p>Since promises are re-written as state machines they also enable an even better
|
||||
syntax where we now can write our last example like this:</p>
|
||||
<pre><code>async function run() {
|
||||
<pre><code class="language-js ignore">async function run() {
|
||||
await timer(200);
|
||||
await timer(100);
|
||||
await timer(50);
|
||||
@@ -1474,16 +1475,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(());
|
||||
}
|
||||
</code></pre></pre>
|
||||
<h1><a class="header" href="#pin" id="pin">Pin</a></h1>
|
||||
|
||||
Reference in New Issue
Block a user