Skip to content

Commit

Permalink
Merge pull request #1 from Detegr/rust_uptodate
Browse files Browse the repository at this point in the history
Update to Rust master

- Send trait is an unsafe trait and cannot be derived anymore
- Change send to send_opt to get rid of panics
- Fix `unused result` warnings
  • Loading branch information
passcod committed Jan 3, 2015
2 parents 9584d7b + dc31c12 commit fd78d0e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
12 changes: 7 additions & 5 deletions src/inotify/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@ impl INotifyWatcher {
Err(e) => {
match e.kind {
IoErrorKind::EndOfFile => break,
_ => tx.send(Event {
path: None,
op: Err(Error::Io(e))
})
_ => {
let _ = tx.send_opt(Event {
path: None,
op: Err(Error::Io(e))
});
}
}
}
}
Expand Down Expand Up @@ -91,7 +93,7 @@ impl Watcher for INotifyWatcher {
},
Err(e) => return Err(Error::Io(e))
};

it.run();
return Ok(it);
}
Expand Down
11 changes: 6 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ pub mod op {
}
}

#[deriving(Send)]
pub struct Event {
pub path: Option<Path>,
pub op: Result<Op, Error>,
}

unsafe impl Send for Event {}

pub enum Error {
Generic(String),
Io(IoError),
Expand All @@ -53,7 +54,7 @@ pub fn new(tx: Sender<Event>) -> Result<RecommendedWatcher, Error> {
#[test]
#[cfg(target_os = "linux")]
fn new_inotify() {
let (tx, rx) = channel();
let (tx, _) = channel();
let w: Result<INotifyWatcher, Error> = Watcher::new(tx);
match w {
Ok(_) => assert!(true),
Expand All @@ -63,7 +64,7 @@ fn new_inotify() {

#[test]
fn new_poll() {
let (tx, rx) = channel();
let (tx, _) = channel();
let w: Result<PollWatcher, Error> = Watcher::new(tx);
match w {
Ok(_) => assert!(true),
Expand All @@ -73,10 +74,10 @@ fn new_poll() {

#[test]
fn new_recommended() {
let (tx, rx) = channel();
let (tx, _) = channel();
let w: Result<RecommendedWatcher, Error> = Watcher::new(tx);
match w {
Ok(_) => assert!(true),
Err(_) => assert!(false)
}
}
}

0 comments on commit fd78d0e

Please sign in to comment.