Skip to main content

negation/
negation.rs

1use std::time::Duration;
2use waitforit::Wait;
3
4fn main() {
5    let filename = "my_dataset.json";
6
7    // assume that our file exists
8    assert!(std::path::Path::new(filename).exists());
9
10    let first_10sec = !Wait::new_elapsed_from_duration(Duration::from_secs(10));
11    let file_updated = Wait::new_file_update(filename);
12    let file_not_exists = !Wait::new_file_exists(filename);
13
14    // either we update the file in the first 10 sec or we wait for it to be deleted
15    let w = (first_10sec & file_updated) | file_not_exists;
16    w.wait(Duration::from_secs(1));
17}