making tests pass on windows

This commit is contained in:
Carl Fredrik Samson
2020-04-05 01:01:56 +02:00
parent 971288868b
commit 5ec0336d66
7 changed files with 29 additions and 26 deletions

View File

@@ -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) {
: &quot;alignstack&quot;
);
}
# #[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!(&quot;Gen1 got value {}&quot;, n);
}
if let GeneratorState::Yielded(n) = pinned2.as_mut().resume() {
if let GeneratorState::Yielded(n) = pinned2.as_mut().resume(()) {
println!(&quot;Gen2 got value {}&quot;, 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>