fixed rustfmt warnings
This commit is contained in:
committed by
Siegfried Kienzle
parent
cef96956a4
commit
733068dc8d
@@ -24,8 +24,8 @@ static GPIO_LED_ON: &'static str = "0";
|
|||||||
static GPIO_LED_OFF: &'static str = "1";
|
static GPIO_LED_OFF: &'static str = "1";
|
||||||
|
|
||||||
fn write(path: &str, value: &str) {
|
fn write(path: &str, value: &str) {
|
||||||
let mut file = File::create(Path::new(path))
|
let mut file = File::create(Path::new(path)).expect(format!("Open file '{}' failed", path)
|
||||||
.expect(format!("Open file '{}' failed", path).as_str());
|
.as_str());
|
||||||
|
|
||||||
file.write_all(value.as_bytes())
|
file.write_all(value.as_bytes())
|
||||||
.expect(format!("Write value '{}' to '{}' file failed", value, path).as_str());
|
.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);
|
println!("Wrote value '{}' to '{}'.", value, path);
|
||||||
}
|
}
|
||||||
fn read(path: &str) -> String {
|
fn read(path: &str) -> String {
|
||||||
let mut file = File::open(Path::new(path))
|
let mut file = File::open(Path::new(path)).expect(format!("Open file '{}' failed", path)
|
||||||
.expect(format!("Open file '{}' failed", path).as_str());
|
.as_str());
|
||||||
let mut contents = String::new();
|
let mut contents = String::new();
|
||||||
|
|
||||||
file.read_to_string(&mut contents)
|
file.read_to_string(&mut contents)
|
||||||
@@ -55,11 +55,13 @@ fn unexport(port: &str) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn set_direction(port: &str, direction: &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) {
|
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 {
|
fn get_value(port: &str) -> String {
|
||||||
String::from(read(format!("/sys/class/gpio/gpio{}/value", port).as_str()).trim())
|
String::from(read(format!("/sys/class/gpio/gpio{}/value", port).as_str()).trim())
|
||||||
|
|||||||
@@ -98,13 +98,19 @@ fn main() {
|
|||||||
{
|
{
|
||||||
let mut ap = ArgumentParser::new();
|
let mut ap = ArgumentParser::new();
|
||||||
ap.set_description(env!("CARGO_PKG_DESCRIPTION"));
|
ap.set_description(env!("CARGO_PKG_DESCRIPTION"));
|
||||||
ap.refer(&mut min).add_option(&["--min"], Store, "Sleep period start");
|
ap.refer(&mut min)
|
||||||
ap.refer(&mut max).add_option(&["--max"], Store, "Sleep period end");
|
.add_option(&["--min"], Store, "Sleep period start");
|
||||||
ap.refer(&mut step).add_option(&["--step"], Store, "Sleep period step size");
|
ap.refer(&mut max)
|
||||||
ap.refer(&mut count).add_option(&["--loop"], Store, "Count of measurements per period");
|
.add_option(&["--max"], Store, "Sleep period end");
|
||||||
|
ap.refer(&mut step)
|
||||||
|
.add_option(&["--step"], Store, "Sleep period step size");
|
||||||
|
ap.refer(&mut count)
|
||||||
|
.add_option(&["--loop"], Store, "Count of measurements per period");
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
ap.refer(&mut realtime).add_option(&["--rt"], StoreTrue, "Set realtime priority");
|
ap.refer(&mut realtime)
|
||||||
ap.refer(&mut output).add_option(&["-o", "--out"], Store, "Output file");
|
.add_option(&["--rt"], StoreTrue, "Set realtime priority");
|
||||||
|
ap.refer(&mut output)
|
||||||
|
.add_option(&["-o", "--out"], Store, "Output file");
|
||||||
ap.add_option(&["-V", "--version"],
|
ap.add_option(&["-V", "--version"],
|
||||||
Print(env!("CARGO_PKG_VERSION").to_string()),
|
Print(env!("CARGO_PKG_VERSION").to_string()),
|
||||||
"Show version");
|
"Show version");
|
||||||
@@ -141,9 +147,8 @@ fn main() {
|
|||||||
match file.as_ref() {
|
match file.as_ref() {
|
||||||
Some(mut f) => {
|
Some(mut f) => {
|
||||||
let value = format!("{: >9} {}\n", duration, duration_to_ns(max_delay.1));
|
let value = format!("{: >9} {}\n", duration, duration_to_ns(max_delay.1));
|
||||||
f.write_all(value.as_bytes()).expect(format!("Write value '{}' to '{}' file failed",
|
f.write_all(value.as_bytes())
|
||||||
value,
|
.expect(format!("Write value '{}' to '{}' file failed", value, output)
|
||||||
output)
|
|
||||||
.as_str());
|
.as_str());
|
||||||
}
|
}
|
||||||
None => {}
|
None => {}
|
||||||
|
|||||||
Reference in New Issue
Block a user