100-exercises-to-learn-rust/exercises/08_futures/04_future/src/lib.rs

17 lines
460 B
Rust
Raw Normal View History

2024-05-16 02:00:48 +08:00
//! 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`.
2024-05-16 16:04:49 +08:00
//! You can wrap existing statements in blocks `{}` if needed.
2024-05-16 02:00:48 +08:00
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);
}