blob: 70811353f094b0ae4de98bbf1d3c7bb8ce319a3f (
plain)
1
2
3
4
5
6
7
8
9
10
|
use std::env;
/// If `name` is set and, after trimming whitespace, is not empty string, then return that trimmed
/// string. Else None.
pub fn get_env_var(name: &str) -> Option<String> {
match env::var(name).unwrap_or("".to_string()).trim() {
"" => None,
non_empty_string => Some(non_empty_string.to_string()),
}
}
|