| Crates.io | settimeout |
| lib.rs | settimeout |
| version | 0.1.2 |
| created_at | 2020-03-02 06:04:01.068808+00 |
| updated_at | 2020-03-02 06:26:12.713892+00 |
| description | Creates a std::future::Future implementation to be ready at some point |
| homepage | https://github.com/rousan/settimeout-rs |
| repository | https://github.com/rousan/settimeout-rs |
| max_upload_size | |
| id | 214368 |
| size | 8,186 |
Provides an implementation of std::future::Future trait to be ready at some point. Sometimes,
it is needed a std::future::Future trait instance for testing purpose in any async function.
Add this to your Cargo.toml:
[dependencies]
settimeout = "0.1.2"
Create a simple std::future::Future implementation:
use futures::executor::block_on;
use std::time::Duration;
use settimeout::set_timeout;
async fn foo() {
println!("The Future will be ready after some time");
set_timeout(Duration::from_secs(5)).await;
println!("Now, it is ready");
}
fn main() {
block_on(foo());
}
Your PRs and stars are always welcome.