Advertisement
Guest User

Untitled

a guest
Sep 4th, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 0.51 KB | None | 0 0
  1. use futures::executor::ThreadPool;
  2. use std::error::Error;
  3.  
  4. async fn foo() -> u8 {
  5.    println!("hi");
  6.         55
  7. }
  8.  
  9. async fn bar() {
  10.         let mut i = 0;
  11.         let mut k = vec!();
  12.         while i < 5 {
  13.                 i = i + 1;
  14.                 k.push(foo());
  15.         }
  16.         for thing in k {
  17.                 thing.await;
  18.  
  19.         }
  20. }
  21.  
  22. fn main() -> Result<(), Box<dyn Error>> {
  23.     let mut pool = ThreadPool::new()?;
  24.     pool.run(bar());
  25.     println!("Hello, world!");
  26.         Ok(())
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement