just/src/load_dotenv.rs

20 lines
470 B
Rust
Raw Normal View History

2018-03-05 13:21:35 -08:00
use common::*;
use dotenv;
pub fn load_dotenv() -> RunResult<'static, Map<String, String>> {
match dotenv::dotenv_iter() {
Ok(iter) => {
let result: dotenv::Result<Map<String, String>> = iter.collect();
result.map_err(|dotenv_error| RuntimeError::Dotenv { dotenv_error })
2018-03-05 13:21:35 -08:00
}
Err(dotenv_error) => {
if dotenv_error.not_found() {
Ok(Map::new())
} else {
Err(RuntimeError::Dotenv { dotenv_error })
}
2018-03-05 13:21:35 -08:00
}
}
}