Hey! I'm having a pretty annoying non-rust-like error with the new version of notify-rs, I have a CLI app that watches some files, it was created and tested with v4. Some days ago I found out that notify has released a new major, so I updated, reviewed the code, applying the changes but now I just have a piece of code that does not throws any error, neither Clippy nor rust-analyzer points out anything strange.
Does anyone knows about that, or is the best way for rust to watch for file changes?
fn main() {
let (tx, rx) = std::sync::mpsc::channel();
let mut watcher = RecommendedWatcher::new(tx, Config::default()).unwrap();
watcher.watch(path.as_ref(), RecursiveMode::Recursive).unwrap();
for res in rx {
match res {
Ok(event) => println!("changed: {:?}", event),
Err(e) => println!("watch error: {:?}", e),
}
}
}
I guess in your case you're not getting anything? I also tried it with a directory and editing/adding/removing files inside it and it seemed to work as expected. I'm on linux (openSUSE),
Yeap, that's a solid boilerplate, I figured out that in my case the thread was busy so, the watcher was created successfully but does not start watching, that's not a runtime error nor syntax, so none of them was giving a message, just simplifying threading stuff solved, but that's for the answer, will help more people overtime! ;D