mirror of
https://github.com/Steffo99/micronfig.git
synced 2024-12-22 20:14:18 +00:00
Use unwrap_or_else
and panic!
instead of expect
and format!
This commit is contained in:
parent
4da9dea5d6
commit
bafdbd888b
2 changed files with 3 additions and 3 deletions
|
@ -21,7 +21,7 @@ pub fn parse_dotenv<P>(value: P) -> Option<DotEnv>
|
|||
|
||||
let mut contents: String = String::new();
|
||||
file.read_to_string(&mut contents)
|
||||
.expect(&format!("to be able to read {value:?}"));
|
||||
.unwrap_or_else(|_| panic!("to be able to read {value:?}"));
|
||||
|
||||
let mut keys: HashMap<OsString, String> = HashMap::new();
|
||||
|
||||
|
|
|
@ -13,11 +13,11 @@ pub fn get(key: &OsStr) -> Option<String> {
|
|||
let path = std::path::PathBuf::from(path);
|
||||
|
||||
let mut file = std::fs::File::open(&path)
|
||||
.expect(&format!("to be able to open file at {path:?}"));
|
||||
.unwrap_or_else(|_| panic!("to be able to open file at {path:?}"));
|
||||
|
||||
let mut data = String::new();
|
||||
file.read_to_string(&mut data)
|
||||
.expect(&format!("to be able to read from file at {path:?}"));
|
||||
.unwrap_or_else(|_| panic!("to be able to read from file at {path:?}"));
|
||||
|
||||
Some(data)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue