Created
February 1, 2023 04:00
-
-
Save Enigo/8c2d2314fba6bf64ee65c266730d8b80 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub fn as_parsed<T: FromStr>(key: &str) -> T | |
where | |
<T as FromStr>::Err: Debug, | |
{ | |
as_string(key) | |
.parse::<T>() | |
.expect(format!("{} should be a valid u16", key).as_str()) | |
} | |
pub fn as_string(key: &str) -> String { | |
String::from( | |
env::var(key) | |
.expect(format!("{} should be set", key).as_str()) | |
.as_str(), | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment