Skip to content

Commit

Permalink
Revert to moving the path instead of borrowing it
Browse files Browse the repository at this point in the history
This reverts commit bb3c978.
  • Loading branch information
passcod committed Aug 24, 2015
1 parent 8857e09 commit 3340d74
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/fsevent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,13 +219,13 @@ impl Watcher for FsEventWatcher {
Ok(fsevent)
}

fn watch<P: AsRef<Path> + ?Sized>(&mut self, path: &P) -> Result<(), Error> {
fn watch<P: AsRef<Path>>(&mut self, path: P) -> Result<(), Error> {
self.stop();
self.append_path(&path.as_ref().to_str().unwrap());
self.run()
}

fn unwatch<P: AsRef<Path> + ?Sized>(&mut self, path: &P) -> Result<(), Error> {
fn unwatch<P: AsRef<Path>>(&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
Expand Down
6 changes: 3 additions & 3 deletions src/inotify/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ impl INotifyWatcher {
});
}

fn add_watch<P: AsRef<Path> + ?Sized>(&mut self, path: &P) -> Result<(), Error> {
fn add_watch<P: AsRef<Path>>(&mut self, path: P) -> Result<(), Error> {
let mut watching = flags::IN_ATTRIB
| flags::IN_CREATE
| flags::IN_DELETE
Expand Down Expand Up @@ -130,7 +130,7 @@ impl Watcher for INotifyWatcher {
return Ok(it);
}

fn watch<P: AsRef<Path> + ?Sized>(&mut self, path: &P) -> Result<(), Error> {
fn watch<P: AsRef<Path>>(&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)),
Expand All @@ -156,7 +156,7 @@ impl Watcher for INotifyWatcher {
}
}

fn unwatch<P: AsRef<Path> + ?Sized>(&mut self, path: &P) -> Result<(), Error> {
fn unwatch<P: AsRef<Path>>(&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
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ pub enum Error {

pub trait Watcher {
fn new(Sender<Event>) -> Result<Self, Error>;
fn watch<P: AsRef<Path> + ?Sized>(&mut self, &P) -> Result<(), Error>;
fn unwatch<P: AsRef<Path> + ?Sized>(&mut self, &P) -> Result<(), Error>;
fn watch<P: AsRef<Path>>(&mut self, P) -> Result<(), Error>;
fn unwatch<P: AsRef<Path>>(&mut self, P) -> Result<(), Error>;
}

#[cfg(target_os = "linux")] pub type RecommendedWatcher = INotifyWatcher;
Expand Down
4 changes: 2 additions & 2 deletions src/null.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ impl Watcher for NullWatcher {
Ok(NullWatcher)
}

fn watch<P: AsRef<Path> + ?Sized>(&mut self, path: &P) -> Result<(), Error> {
fn watch<P: AsRef<Path>>(&mut self, path: P) -> Result<(), Error> {
Ok(())
}

fn unwatch<P: AsRef<Path> + ?Sized>(&mut self, path: &P) -> Result<(), Error> {
fn unwatch<P: AsRef<Path>>(&mut self, path: P) -> Result<(), Error> {
Ok(())
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/poll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,12 @@ impl Watcher for PollWatcher {
Ok(p)
}

fn watch<P: AsRef<Path> + ?Sized>(&mut self, path: &P) -> Result<(), Error> {
fn watch<P: AsRef<Path>>(&mut self, path: P) -> Result<(), Error> {
(*self.watches).write().unwrap().insert(path.as_ref().to_path_buf());
Ok(())
}

fn unwatch<P: AsRef<Path> + ?Sized>(&mut self, path: &P) -> Result<(), Error> {
fn unwatch<P: AsRef<Path>>(&mut self, path: P) -> Result<(), Error> {
if (*self.watches).write().unwrap().remove(path.as_ref()) {
Ok(())
} else {
Expand Down

0 comments on commit 3340d74

Please sign in to comment.