just/src/load_dotenv.rs
2018-03-05 13:21:35 -08:00

18 lines
442 B
Rust

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})
}
Err(dotenv_error) => if dotenv_error.not_found() {
Ok(Map::new())
} else {
Err(RuntimeError::Dotenv{dotenv_error})
}
}
}