Last chapter on async Rust
This commit is contained in:
1 parent
6e581440bf
commit
aa58dcb5ca
33 files changed
+1799
-10
No files matched your search
@@ -0,0 +1,7 @@
|
||||
[package]
|
||||
name = "future"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
tokio = { version = "1", features = ["full"] }
|
||||
@@ -0,0 +1,15 @@
|
||||
//! TODO: get the code to compile by **re-ordering** the statements
|
||||
//! in the `example` function. You're not allowed to change the
|
||||
//! `spawner` function nor what each line does in `example`.
|
||||
use std::rc::Rc;
|
||||
use tokio::task::yield_now;
|
||||
|
||||
fn spawner() {
|
||||
tokio::spawn(example());
|
||||
}
|
||||
|
||||
async fn example() {
|
||||
let non_send = Rc::new(1);
|
||||
yield_now().await;
|
||||
println!("{}", non_send);
|
||||
}
|
||||
Reference in new issue
Block a user