From 3340d7401230be5f5ed59956b29f8db3a1c12d1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fe=CC=81lix=20Saparelli?= Date: Mon, 24 Aug 2015 09:53:12 +0200 Subject: [PATCH] Revert to moving the path instead of borrowing it This reverts commit bb3c97883edecc90c74c9dff7b91baed67aa2964. --- src/fsevent.rs | 4 ++-- src/inotify/mod.rs | 6 +++--- src/lib.rs | 4 ++-- src/null.rs | 4 ++-- src/poll.rs | 4 ++-- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/fsevent.rs b/src/fsevent.rs index cea1c965..2d7d901d 100644 --- a/src/fsevent.rs +++ b/src/fsevent.rs @@ -219,13 +219,13 @@ impl Watcher for FsEventWatcher { Ok(fsevent) } - fn watch + ?Sized>(&mut self, path: &P) -> Result<(), Error> { + fn watch>(&mut self, path: P) -> Result<(), Error> { self.stop(); self.append_path(&path.as_ref().to_str().unwrap()); self.run() } - fn unwatch + ?Sized>(&mut self, path: &P) -> Result<(), Error> { + fn unwatch>(&mut self, path: P) -> Result<(), Error> { self.stop(); self.remove_path(&path.as_ref().to_str().unwrap()); // ignore return error: may be empty path list diff --git a/src/inotify/mod.rs b/src/inotify/mod.rs index 525ede10..1831bca6 100644 --- a/src/inotify/mod.rs +++ b/src/inotify/mod.rs @@ -49,7 +49,7 @@ impl INotifyWatcher { }); } - fn add_watch + ?Sized>(&mut self, path: &P) -> Result<(), Error> { + fn add_watch>(&mut self, path: P) -> Result<(), Error> { let mut watching = flags::IN_ATTRIB | flags::IN_CREATE | flags::IN_DELETE @@ -130,7 +130,7 @@ impl Watcher for INotifyWatcher { return Ok(it); } - fn watch + ?Sized>(&mut self, path: &P) -> Result<(), Error> { + fn watch>(&mut self, path: P) -> Result<(), Error> { let is_dir = match metadata(&path.as_ref()) { Ok(m) => m.is_dir(), Err(e) => return Err(Error::Io(e)), @@ -156,7 +156,7 @@ impl Watcher for INotifyWatcher { } } - fn unwatch + ?Sized>(&mut self, path: &P) -> Result<(), Error> { + fn unwatch>(&mut self, path: P) -> Result<(), Error> { // FIXME: // once Rust 1.1 is released, just use a &Path // Relevant bug is /~https://github.com/rust-lang/rust/pull/25060 diff --git a/src/lib.rs b/src/lib.rs index 53530409..78da7671 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -50,8 +50,8 @@ pub enum Error { pub trait Watcher { fn new(Sender) -> Result; - fn watch + ?Sized>(&mut self, &P) -> Result<(), Error>; - fn unwatch + ?Sized>(&mut self, &P) -> Result<(), Error>; + fn watch>(&mut self, P) -> Result<(), Error>; + fn unwatch>(&mut self, P) -> Result<(), Error>; } #[cfg(target_os = "linux")] pub type RecommendedWatcher = INotifyWatcher; diff --git a/src/null.rs b/src/null.rs index b0621f4b..456c516d 100644 --- a/src/null.rs +++ b/src/null.rs @@ -11,11 +11,11 @@ impl Watcher for NullWatcher { Ok(NullWatcher) } - fn watch + ?Sized>(&mut self, path: &P) -> Result<(), Error> { + fn watch>(&mut self, path: P) -> Result<(), Error> { Ok(()) } - fn unwatch + ?Sized>(&mut self, path: &P) -> Result<(), Error> { + fn unwatch>(&mut self, path: P) -> Result<(), Error> { Ok(()) } } diff --git a/src/poll.rs b/src/poll.rs index 3f3462fb..5760f1b9 100644 --- a/src/poll.rs +++ b/src/poll.rs @@ -146,12 +146,12 @@ impl Watcher for PollWatcher { Ok(p) } - fn watch + ?Sized>(&mut self, path: &P) -> Result<(), Error> { + fn watch>(&mut self, path: P) -> Result<(), Error> { (*self.watches).write().unwrap().insert(path.as_ref().to_path_buf()); Ok(()) } - fn unwatch + ?Sized>(&mut self, path: &P) -> Result<(), Error> { + fn unwatch>(&mut self, path: P) -> Result<(), Error> { if (*self.watches).write().unwrap().remove(path.as_ref()) { Ok(()) } else {