Skip to content

Commit

Permalink
Merge pull request #61 from pheki/fix-tokio
Browse files Browse the repository at this point in the history
Fix compilation with use_tokio feature
  • Loading branch information
nastevens authored Mar 11, 2020
2 parents 62e267c + 0ee1da0 commit e61d4e1
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ use std::fs;
use std::fs::File;
use std::io;
use std::io::prelude::*;
#[cfg(any(target_os = "linux", target_os = "android"))]
#[cfg(any(target_os = "linux", target_os = "android", feature = "use_tokio"))]
use std::io::SeekFrom;
use std::os::unix::prelude::*;
use std::path::Path;
Expand Down Expand Up @@ -102,7 +102,7 @@ macro_rules! try_unexport {
match $e {
Ok(res) => res,
Err(e) => {
try!($gpio.unexport());
$gpio.unexport()?;
return Err(e);
}
}
Expand All @@ -123,7 +123,7 @@ fn flush_input_from_file(dev_file: &mut File, max: usize) -> io::Result<usize> {
}

/// Get the pin value from the provided file
#[cfg(any(target_os = "linux", target_os = "android"))]
#[cfg(any(target_os = "linux", target_os = "android", feature = "use_tokio"))]
fn get_value_from_file(dev_file: &mut File) -> Result<u8> {
let mut s = String::with_capacity(10);
dev_file.seek(SeekFrom::Start(0))?;
Expand Down Expand Up @@ -217,8 +217,8 @@ impl Pin {
/// let gpio = Pin::new(24);
/// let res = gpio.with_exported(|| {
/// println!("At this point, the Pin is exported");
/// try!(gpio.set_direction(Direction::Low));
/// try!(gpio.set_value(1));
/// gpio.set_direction(Direction::Low)?;
/// gpio.set_value(1)?;
/// // ...
/// Ok(())
/// });
Expand Down Expand Up @@ -731,7 +731,7 @@ impl Stream for PinValueStream {
fn poll(&mut self) -> Poll<Option<Self::Item>, Self::Error> {
match self.0.poll() {
Ok(Async::Ready(Some(()))) => {
let value = try!(self.get_value());
let value = self.get_value()?;
Ok(Async::Ready(Some(value)))
}
Ok(Async::Ready(None)) => Ok(Async::Ready(None)),
Expand Down

0 comments on commit e61d4e1

Please sign in to comment.