This crate makes it easy to "just run" a future.
It offers two simple functions run
and timeout
that
will drive a future to completion on a single thread.
You can easily view all of the source code as it is all
contained within lib.rs
Executing a future without a timeout is as easy as calling
run
with the future.
rust
let future = std::future::ready(69);
let result = rtv::run(future);
assert!(result == 69);
The timeout
function returns an Option
which will be Some(T)
when the future sucesfully completed and None
if the time ran out.
rust
let future = std::future::pending();
let result: Option<()> = rtv::timeout(future, std::time::Duration::from_secs(2));
assert!(result == None)
Earlier versions of this crate were completely different. Rtv used to be a crate for doing recursive-file-traversal but since it was pretty useless I decided to reuse the name for something better.