From a6deba1025a94569d34fe50af387f44585aa3867 Mon Sep 17 00:00:00 2001 From: Mattis Marjak Date: Fri, 4 Dec 2015 17:11:53 +0200 Subject: [PATCH 1/2] derive Debug for Pin and PinPoller "fmt::Debug implementations should be implemented for all public types" source: http://doc.rust-lang.org/std/fmt/ --- src/lib.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 145697ded..04a3d4ed7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -57,6 +57,7 @@ use std::fs::{File}; mod error; pub use error::Error; +#[derive(Debug)] pub struct Pin { pin_num : u64, } @@ -325,6 +326,7 @@ impl Pin { } } +#[derive(Debug)] pub struct PinPoller { pin_num : u64, epoll_fd : RawFd, From 2ffd4609cd3520435197486b0d41c2f2e9f1f997 Mon Sep 17 00:00:00 2001 From: Mattis Marjak Date: Fri, 4 Dec 2015 17:15:18 +0200 Subject: [PATCH 2/2] use File::open in read_from_device_file --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 04a3d4ed7..ceb745d5f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -110,7 +110,7 @@ impl Pin { fn read_from_device_file(&self, dev_file_name: &str) -> io::Result { let gpio_path = format!("/sys/class/gpio/gpio{}/{}", self.pin_num, dev_file_name); - let mut dev_file = try!(File::create(&gpio_path)); + let mut dev_file = try!(File::open(&gpio_path)); let mut s = String::new(); try!(dev_file.read_to_string(&mut s)); Ok(s)