Closed JakeRoggenbuck closed 1 year ago
In green is just contains function calls for the file.
Here is the code for that.
fn read_lid_state(&self) -> Result<LidState, Error> { if !self.found_path { return Ok(LidState::Unapplicable); } let lid_str = fs::read_to_string(self.best_path)?; let state = if lid_str.contains("open") { LidState::Open } else if lid_str.contains("closed") { LidState::Closed } else { LidState::Unknown }; Ok(state) }
The two contains checks could probably be more optimized with another type of check.
We could convert to a prim type and use a match?
wdym?
In green is just contains function calls for the file.
Here is the code for that.
The two contains checks could probably be more optimized with another type of check.