Skip to content

Commit

Permalink
fix futures example to work with current nightly (2019-08-18)
Browse files Browse the repository at this point in the history
  • Loading branch information
fkohlgrueber authored and koute committed Aug 20, 2019
1 parent cc96683 commit adcf682
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion examples/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[workspace]
members = ["canvas", "drag", "echo", "gamepad", "hasher", "minimal", "todomvc", "webgl", "wasm-bindgen-minimal"]
members = ["canvas", "drag", "echo", "futures", "gamepad", "hasher", "minimal", "todomvc", "webgl", "wasm-bindgen-minimal"]
16 changes: 8 additions & 8 deletions examples/futures/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(async_await, await_macro)]
#![feature(async_await)]

#[macro_use]
extern crate stdweb;
Expand All @@ -24,32 +24,32 @@ fn javascript_promise() -> PromiseFuture< u32 > {

async fn print( message: &str ) {
// Waits for 2000 milliseconds
await!( wait( 2000 ) );
wait( 2000 ).await;
console!( log, message );
}


async fn future_main() -> Result< (), Error > {
// Runs Futures synchronously
await!( print( "Hello" ) );
await!( print( "There" ) );
print( "Hello" ).await;
print( "There" ).await;

{
// Runs multiple Futures in parallel
let ( a, b ) = await!( join(
let ( a, b ) = join(
print( "Test 1" ),
print( "Test 2" ),
) );
).await;

console!( log, "join", a, b );
}

{
// Runs multiple Futures (which can error) in parallel
let ( a, b ) = await!( try_join(
let ( a, b ) = try_join(
javascript_promise(),
javascript_promise(),
) )?;
).await?;

console!( log, "try_join", a, b );
}
Expand Down

0 comments on commit adcf682

Please sign in to comment.