Skip to content

Commit 8c95845

Browse files
authored
Merge pull request #33 from Razican/clippy_fixes
Fixed a bunch of clippy warnings and errors
2 parents d2c65a1 + cf72792 commit 8c95845

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

examples/blinky.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
// option. This file may not be copied, modified, or distributed
77
// except according to those terms.
88

9-
#[macro_use]
109
extern crate sysfs_gpio;
1110

1211
use sysfs_gpio::{Direction, Pin};

examples/interrupt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ fn interrupt(pin: u64) -> sysfs_gpio::Result<()> {
2424
Some(value) => println!("{}", value),
2525
None => {
2626
let mut stdout = stdout();
27-
try!(stdout.write(b"."));
27+
try!(stdout.write_all(b"."));
2828
try!(stdout.flush());
2929
}
3030
}

src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,8 @@ impl Pin {
172172

173173
// determine if this is valid and figure out the pin_num
174174
if !try!(fs::metadata(&pb)).is_dir() {
175-
return Err(Error::Unexpected(format!("Provided path not a directory or symlink to \
176-
a directory")));
175+
return Err(Error::Unexpected("Provided path not a directory or symlink to \
176+
a directory".to_owned()));
177177
}
178178

179179
let re = regex::Regex::new(r"^/sys/.*?/gpio/gpio(\d+)$").unwrap();
@@ -268,7 +268,7 @@ impl Pin {
268268
/// }
269269
/// ```
270270
pub fn export(&self) -> Result<()> {
271-
if let Err(_) = fs::metadata(&format!("/sys/class/gpio/gpio{}", self.pin_num)) {
271+
if fs::metadata(&format!("/sys/class/gpio/gpio{}", self.pin_num)).is_err() {
272272
let mut export_file = try!(File::create("/sys/class/gpio/export"));
273273
try!(export_file.write_all(format!("{}", self.pin_num).as_bytes()));
274274
}
@@ -282,7 +282,7 @@ impl Pin {
282282
/// exported, it will return without error. That is, whenever
283283
/// this function returns Ok, the GPIO is not exported.
284284
pub fn unexport(&self) -> Result<()> {
285-
if let Ok(_) = fs::metadata(&format!("/sys/class/gpio/gpio{}", self.pin_num)) {
285+
if fs::metadata(&format!("/sys/class/gpio/gpio{}", self.pin_num)).is_ok() {
286286
let mut unexport_file = try!(File::create("/sys/class/gpio/unexport"));
287287
try!(unexport_file.write_all(format!("{}", self.pin_num).as_bytes()));
288288
}

0 commit comments

Comments
 (0)