just/src/load_dotenv.rs

18 lines
479 B
Rust
Raw Normal View History

use crate::common::*;
2018-03-05 13:21:35 -08:00
pub fn load_dotenv() -> RunResult<'static, BTreeMap<String, String>> {
2018-03-05 13:21:35 -08:00
match dotenv::dotenv_iter() {
Ok(iter) => {
let result: dotenv::Result<BTreeMap<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(BTreeMap::new())
} else {
Err(RuntimeError::Dotenv { dotenv_error })
}
2018-03-05 13:21:35 -08:00
}
}
}