Something like dotenv. Like-dotenv loads the key/value pairs from .env
file, and sets them to environment variables.
Please create a .env
file like below.
# This is a comment.
SAMPLE_KEY1=SAMPLE_VALUE1
SAMPLE_KEY2="SAMPLE_VALUE2"
You can call like_dotenv::config()
like below.
use std::env;
fn main() {
like_dotenv::config().unwrap();
for (key, value) in env::vars() {
println!("{key}: {value}");
/*
Output:
SAMPLE_KEY1: SAMPLE_VALUE1
SAMPLE_KEY2: SAMPLE_VALUE2
...other environment variables
*/
}
}