fixed rustfmt warnings

This commit is contained in:
Simon Wörner
2017-04-06 16:40:19 +02:00
committed by Siegfried Kienzle
parent cef96956a4
commit 733068dc8d
2 changed files with 23 additions and 16 deletions

View File

@@ -24,8 +24,8 @@ static GPIO_LED_ON: &'static str = "0";
static GPIO_LED_OFF: &'static str = "1";
fn write(path: &str, value: &str) {
let mut file = File::create(Path::new(path))
.expect(format!("Open file '{}' failed", path).as_str());
let mut file = File::create(Path::new(path)).expect(format!("Open file '{}' failed", path)
.as_str());
file.write_all(value.as_bytes())
.expect(format!("Write value '{}' to '{}' file failed", value, path).as_str());
@@ -34,8 +34,8 @@ fn write(path: &str, value: &str) {
println!("Wrote value '{}' to '{}'.", value, path);
}
fn read(path: &str) -> String {
let mut file = File::open(Path::new(path))
.expect(format!("Open file '{}' failed", path).as_str());
let mut file = File::open(Path::new(path)).expect(format!("Open file '{}' failed", path)
.as_str());
let mut contents = String::new();
file.read_to_string(&mut contents)
@@ -55,11 +55,13 @@ fn unexport(port: &str) {
}
fn set_direction(port: &str, direction: &str) {
write(format!("/sys/class/gpio/gpio{}/direction", port).as_str(), direction);
write(format!("/sys/class/gpio/gpio{}/direction", port).as_str(),
direction);
}
fn set_value(port: &str, value: &str) {
write(format!("/sys/class/gpio/gpio{}/value", port).as_str(), value);
write(format!("/sys/class/gpio/gpio{}/value", port).as_str(),
value);
}
fn get_value(port: &str) -> String {
String::from(read(format!("/sys/class/gpio/gpio{}/value", port).as_str()).trim())