[refactor] Refactor Option/Result combinators (#3180)

Code simplifications using `Option`/`Result` combinators to make pattern-matches a tad simpler. 
Opinions on these loosely held, happy to adjust in review.

Tool-aided by [comby-rust](https://github.com/huitseeker/comby-rust).
This commit is contained in:
François Garillot
2022-05-16 01:59:47 +00:00
parent e81a428ffb
commit 3f9e83e840
5 changed files with 19 additions and 26 deletions

View File

@@ -210,10 +210,8 @@ pub fn load_enr_from_disk(dir: &Path) -> Result<Enr, String> {
let mut enr_string = String::new();
match enr_file.read_to_string(&mut enr_string) {
Err(_) => Err("Could not read ENR from file".to_string()),
Ok(_) => match Enr::from_str(&enr_string) {
Ok(disk_enr) => Ok(disk_enr),
Err(e) => Err(format!("ENR from file could not be decoded: {:?}", e)),
},
Ok(_) => Enr::from_str(&enr_string)
.map_err(|e| format!("ENR from file could not be decoded: {:?}", e)),
}
}