Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed unused import and clippy warnings #535

Merged
merged 3 commits into from
Sep 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions examples/debouncer_mini.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
use std::{io::Write, path::Path, time::Duration};
use std::{path::Path, time::Duration};

use notify::RecursiveMode;
use notify_debouncer_mini::new_debouncer;

/// Example for debouncer mini
fn main() {
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("debouncer_mini=trace")).init();
env_logger::Builder::from_env(
env_logger::Env::default().default_filter_or("debouncer_mini=trace"),
)
.init();
// emit some events by changing a file
std::thread::spawn(|| {
let path = Path::new("test.txt");
Expand Down Expand Up @@ -40,7 +43,9 @@ fn main() {
// print all events, non returning
for result in rx {
match result {
Ok(events) => events.iter().for_each(|event| log::info!("Event {event:?}")),
Ok(events) => events
.iter()
.for_each(|event| log::info!("Event {event:?}")),
Err(error) => log::info!("Error {error:?}"),
}
}
Expand Down
10 changes: 4 additions & 6 deletions examples/debouncer_mini_custom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,11 @@ fn main() {
// notify backend configuration
let backend_config = notify::Config::default().with_poll_interval(Duration::from_secs(1));
// debouncer configuration
let debouncer_config = Config::default().with_timeout(Duration::from_millis(1000)).with_notify_config(backend_config);
let debouncer_config = Config::default()
.with_timeout(Duration::from_millis(1000))
.with_notify_config(backend_config);
// select backend via fish operator, here PollWatcher backend
let mut debouncer = new_debouncer_opt::<_, notify::PollWatcher>(
debouncer_config,
tx,
)
.unwrap();
let mut debouncer = new_debouncer_opt::<_, notify::PollWatcher>(debouncer_config, tx).unwrap();

debouncer
.watcher()
Expand Down
17 changes: 8 additions & 9 deletions examples/pollwatcher_manual.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,21 @@ fn main() {
fn watch<P: AsRef<Path>>(path: P) -> notify::Result<()> {
let (tx, rx) = std::sync::mpsc::channel();
// use the PollWatcher and disable automatic polling
let mut watcher = PollWatcher::new(
tx,
Config::default().with_manual_polling(),
)?;
let mut watcher = PollWatcher::new(tx, Config::default().with_manual_polling())?;

// Add a path to be watched. All files and directories at that path and
// below will be monitored for changes.
watcher.watch(path.as_ref(), RecursiveMode::Recursive)?;

// run event receiver on a different thread, we want this one for user input
std::thread::spawn(move ||{for res in rx {
match res {
Ok(event) => println!("changed: {:?}", event),
Err(e) => println!("watch error: {:?}", e),
std::thread::spawn(move || {
for res in rx {
match res {
Ok(event) => println!("changed: {:?}", event),
Err(e) => println!("watch error: {:?}", e),
}
}
}});
});

// wait for any input and poll
loop {
Expand Down
4 changes: 2 additions & 2 deletions notify-debouncer-full/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@
//! - `crossbeam` enabled by default, adds [`DebounceEventHandler`](DebounceEventHandler) support for crossbeam channels.
//! Also enables crossbeam-channel in the re-exported notify. You may want to disable this when using the tokio async runtime.
//! - `serde` enables serde support for events.
//!
//!
//! # Caveats
//!
//!
//! As all file events are sourced from notify, the [known problems](https://docs.rs/notify/latest/notify/#known-problems) section applies here too.

mod cache;
Expand Down
6 changes: 3 additions & 3 deletions notify-debouncer-mini/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
//! // Add a path to be watched. All files and directories at that path and
//! // below will be monitored for changes.
//! debouncer.watcher().watch(Path::new("."), RecursiveMode::Recursive).unwrap();
//!
//!
//! // note that dropping the debouncer (as will happen here) also ends the debouncer
//! // thus this demo would need an endless loop to keep running
//! # }
Expand All @@ -48,9 +48,9 @@
//! - `crossbeam` enabled by default, adds [`DebounceEventHandler`](DebounceEventHandler) support for crossbeam channels.
//! Also enables crossbeam-channel in the re-exported notify. You may want to disable this when using the tokio async runtime.
//! - `serde` enables serde support for events.
//!
//!
//! # Caveats
//!
//!
//! As all file events are sourced from notify, the [known problems](https://docs.rs/notify/latest/notify/#known-problems) section applies here too.
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
Expand Down
6 changes: 3 additions & 3 deletions notify/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl Config {
/// file trees so it is recommended to measure and tune accordingly.
///
/// The default poll frequency is 30 seconds.
///
///
/// This will enable automatic polling, overwriting [with_manual_polling](Config::with_manual_polling).
pub fn with_poll_interval(mut self, dur: Duration) -> Self {
// TODO: v7.0 break signature to option
Expand All @@ -76,9 +76,9 @@ impl Config {
}

/// For the [PollWatcher](crate::PollWatcher) backend.
///
///
/// Disable automatic polling. Requires calling [crate::PollWatcher::poll] manually.
///
///
/// This will disable automatic polling, overwriting [with_poll_interval](Config::with_poll_interval).
pub fn with_manual_polling(mut self) -> Self {
self.poll_interval = None;
Expand Down
2 changes: 1 addition & 1 deletion notify/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ impl Error {

/// Creates a new "invalid config" error from the given `Config`.
pub fn invalid_config(config: &Config) -> Self {
Self::new(ErrorKind::InvalidConfig(config.clone()))
Self::new(ErrorKind::InvalidConfig(*config))
}
}

Expand Down
4 changes: 1 addition & 3 deletions notify/src/inotify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,7 @@ impl EventLoop {
}

let path = match event.name {
Some(name) => {
self.paths.get(&event.wd).map(|root| root.join(&name))
}
Some(name) => self.paths.get(&event.wd).map(|root| root.join(name)),
None => self.paths.get(&event.wd).cloned(),
};

Expand Down
10 changes: 5 additions & 5 deletions notify/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@
//! Note the `macos_kqueue` requirement here, otherwise no native backend is available on macos.
//!
//! # Known Problems
//!
//!
//! ### Network filesystems
//!
//!
//! Network mounted filesystems like NFS may not emit any events for notify to listen to.
//! This applies especially to WSL programs watching windows paths ([issue #254](https://github.com/notify-rs/notify/issues/254)).
//!
//!
//! A workaround is the [PollWatcher] backend.
//!
//! ### Docker with Linux on MacOS M1
Expand Down Expand Up @@ -92,10 +92,10 @@
//! Note that the [PollWatcher] is not restricted by this limitation, so it may be an alternative if your users can't increase the limit.
//!
//! ### Watching large directories
//!
//!
//! When watching a very large amount of files, notify may fail to receive all events.
//! For example the linux backend is documented to not be a 100% reliable source. See also issue [#412](https://github.com/notify-rs/notify/issues/412).
//!
//!
//! # Examples
//!
//! For more examples visit the [examples folder](https://github.com/notify-rs/notify/tree/main/examples) in the repository.
Expand Down