just/src/load_dotenv.rs
Casey Rodarmor 3a287b864a
Housekeeping (#394)
- Upgrade to rust 2018
- Update dependencies
- Use BTree{Map,Set} instead of Map and Set
2019-04-11 15:23:14 -07:00

18 lines
479 B
Rust

use crate::common::*;
pub fn load_dotenv() -> RunResult<'static, BTreeMap<String, String>> {
match dotenv::dotenv_iter() {
Ok(iter) => {
let result: dotenv::Result<BTreeMap<String, String>> = iter.collect();
result.map_err(|dotenv_error| RuntimeError::Dotenv { dotenv_error })
}
Err(dotenv_error) => {
if dotenv_error.not_found() {
Ok(BTreeMap::new())
} else {
Err(RuntimeError::Dotenv { dotenv_error })
}
}
}
}