https://github.com/rousan/settimeout-rs
A Rust library to create a std::future::Future implementation to be used in any async function
https://github.com/rousan/settimeout-rs
future rust settimeout
Last synced: 9 months ago
JSON representation
A Rust library to create a std::future::Future implementation to be used in any async function
- Host: GitHub
- URL: https://github.com/rousan/settimeout-rs
- Owner: rousan
- License: mit
- Created: 2020-03-01T20:51:43.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-03-02T06:25:56.000Z (about 6 years ago)
- Last Synced: 2024-10-11T14:38:43.907Z (over 1 year ago)
- Topics: future, rust, settimeout
- Language: Rust
- Homepage:
- Size: 13.7 KB
- Stars: 8
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://crates.io/crates/settimeout)
[](https://docs.rs/settimeout/)
[](https://github.com/rousan/settimeout-rs)
# settimeout-rs
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.
## Usage
Add this to your Cargo.toml:
```toml
[dependencies]
settimeout = "0.1.2"
```
## Examples
Create a simple `std::future::Future` implementation:
```rust
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());
}
```
## Contributing
Your PRs and stars are always welcome.