diff --git a/V1/led5/src/main.rs b/V1/led5/src/main.rs index fea4313..f5e750b 100644 --- a/V1/led5/src/main.rs +++ b/V1/led5/src/main.rs @@ -40,20 +40,17 @@ static GPIO_BTN_ON: &'static str = "0"; static GPIO_LED_ON: &'static str = "0"; static GPIO_LED_OFF: &'static str = "1"; -fn open(path: &str) -> File { - return File::open(Path::new(path)) - .expect(format!("Open file '{}' failed", path).as_str()); -} - fn write(path: &str, value: &str) { - let mut file = open(path); + 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()); } fn read(path: &str) -> String { - let mut file = open(path); + 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)