diff --git a/V1/led5/src/main.rs b/V1/led5/src/main.rs index df47b06..ab91e63 100644 --- a/V1/led5/src/main.rs +++ b/V1/led5/src/main.rs @@ -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()) diff --git a/V2/sleep/src/main.rs b/V2/sleep/src/main.rs index 7ed1183..7bb508e 100644 --- a/V2/sleep/src/main.rs +++ b/V2/sleep/src/main.rs @@ -98,13 +98,19 @@ fn main() { { let mut ap = ArgumentParser::new(); ap.set_description(env!("CARGO_PKG_DESCRIPTION")); - ap.refer(&mut min).add_option(&["--min"], Store, "Sleep period start"); - ap.refer(&mut max).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"); + ap.refer(&mut min) + .add_option(&["--min"], Store, "Sleep period start"); + ap.refer(&mut max) + .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")] - ap.refer(&mut realtime).add_option(&["--rt"], StoreTrue, "Set realtime priority"); - ap.refer(&mut output).add_option(&["-o", "--out"], Store, "Output file"); + ap.refer(&mut realtime) + .add_option(&["--rt"], StoreTrue, "Set realtime priority"); + ap.refer(&mut output) + .add_option(&["-o", "--out"], Store, "Output file"); ap.add_option(&["-V", "--version"], Print(env!("CARGO_PKG_VERSION").to_string()), "Show version"); @@ -141,10 +147,9 @@ fn main() { match file.as_ref() { Some(mut f) => { 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", - value, - output) - .as_str()); + f.write_all(value.as_bytes()) + .expect(format!("Write value '{}' to '{}' file failed", value, output) + .as_str()); } None => {} }