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