Skip to content

Commit 12a026d

Browse files
authored
fix: make PathsMut::commit consuming (#695)
1 parent d824023 commit 12a026d

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

notify/src/fsevent.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ impl PathsMut for FsEventPathsMut<'_> {
283283
self.0.remove_path(path)
284284
}
285285

286-
fn commit(&mut self) -> Result<()> {
286+
fn commit(self: Box<Self>) -> Result<()> {
287287
// ignore return error: may be empty path list
288288
let _ = self.0.run();
289289
Ok(())

notify/src/lib.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -303,8 +303,11 @@ pub trait PathsMut {
303303
/// Remove a path from watching. See [`Watcher::unwatch`] for more.
304304
fn remove(&mut self, path: &Path) -> Result<()>;
305305

306-
/// Ensure previously added/removed paths are applied.
307-
fn commit(&mut self) -> Result<()>;
306+
/// Ensure added/removed paths are applied.
307+
///
308+
/// The behaviour of dropping a [`PathsMut`] without calling [`commit`] is unspecified.
309+
/// The implementation is free to ignore the changes or not, and may leave the watcher in a started or stopped state.
310+
fn commit(self: Box<Self>) -> Result<()>;
308311
}
309312

310313
/// Type that can deliver file activity notifications
@@ -371,7 +374,7 @@ pub trait Watcher {
371374
fn remove(&mut self, path: &Path) -> Result<()> {
372375
self.0.unwatch(path)
373376
}
374-
fn commit(&mut self) -> Result<()> {
377+
fn commit(self: Box<Self>) -> Result<()> {
375378
Ok(())
376379
}
377380
}

0 commit comments

Comments
 (0)