Simple awaiter implementation in Rust
```rs use std::time::Duration; use waitnotawait::Await;
let mut awaiter = Await::new(move || { std::thread::sleep(Duration::from_secs(3));
"Hello, Wolrd!".to_string()
});
if let Some(result) = awaiter.wait(None) { println!("Result: {}", result); } ```
```rs use std::time::Duration; use waitnotawait::Await;
fn asynchelloworld() -> Await
"Hello, World!".to_string()
})
}
println!("{}", asynchelloworld().wait(None).unwrap()); ```
```rs use std::time::Duration; use waitnotawait::Await;
let awaiter = Await::new(move || { std::thread::sleep(Duration::from_secs(3));
"Hello, Wolrd!".to_string()
});
awaiter.then(move |result| { println!("Task result: {}", result); }); ```
```rs use std::time::Duration; use waitnotawait::Await;
fn asynchelloworld() -> Await
"Hello, World!".to_string()
})
}
let mut awaiter = asynchelloworld(); let mut i = 1;
while let None = awaiter.result() { println!("Waiting for result: {}", i);
i += 1;
}
println!("{}", awaiter.result().unwrap()); ```
Author: Nikita Podvirnyy
Licensed under MIT