7 releases
0.2.1 | Jan 16, 2022 |
---|---|
0.2.0 | Jan 16, 2022 |
0.1.4 | Jan 15, 2022 |
#45 in #timeout
3KB
Set_time_out by UniCorp and LabLer for Rust
Add to cargo.toml the dependency
set_time_out = "0.2.1"
Easy peasy.
Import the function and used.
use set_time_out::set_time_out;
or
use set_time_out::set_time_out_callback;
and invoque
fn say_hello() {
println!("Hello");
}
set_time_out(1500);
say_hello();
done!.
But if you need pass one function, here the correct way. It's the same, but more organized.
fn say_hello() {
println!("Hello");
}
set_time_out_callback(1000, Same(say_hello));
or without callback
fn say_hello() {
println!("Hello");
}
set_time_out_callback(1000, None);
say_hello();
The time is in milliseconds. Have nice day.