| Crates.io | set_time_out |
| lib.rs | set_time_out |
| version | 0.2.1 |
| created_at | 2022-01-15 18:16:40.924188+00 |
| updated_at | 2022-01-16 14:53:38.908112+00 |
| description | Function to delay the execution of a function |
| homepage | https://github.com/LucianoRicardo737/set_time_out_rust |
| repository | https://github.com/LucianoRicardo737/set_time_out_rust |
| max_upload_size | |
| id | 514452 |
| size | 2,462 |
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.