Function envmnt::evaluate_and_load_file
source ·
[−]pub fn evaluate_and_load_file<F>(file: &str, evaluate: F) -> EnvmntResult<()> where
F: Fn(String, String) -> Option<(String, String)>, Expand description
Parses the provided env file and loads all environment variables.
Arguments
file- The file path to load and parseevaluate- Evalute function which will modify the key and value before it is loaded into the environment
Example
fn main() {
let eval_env = |key: String, value: String| {
let mut updated_value = String::from("PREFIX-");
updated_value.push_str(&value);
Some((key, updated_value))
};
let output = envmnt::evaluate_and_load_file("./src/test/var.env", eval_env);
assert!(output.is_ok());
}