3 releases
0.1.2 | Oct 21, 2021 |
---|---|
0.1.1 | Oct 21, 2021 |
0.1.0 | Oct 21, 2021 |
#52 in #env-file
5KB
63 lines
rustdotenv
A tool to load env files into the environment
Install
Add to your cargo.toml
file
[dependencies]
rustdotenv = "0.1.2"
Usage
.env
file
MONGO_URI=mongodb://admin:password@127.0.0.1:27017/?authSource=admin
main.rs
file
use rustdotenv::load;
fn main() {
// If u don't provide the optional Vec<String> then it will load as default the .env file
load(None);
let result = std::env::var("MONGO_URI");
if result.is_err() {
println!("MONGO_URI env var not found");
} else {
println!("MONGO_URI: {}", result.unwrap())
}
}
lib.rs
:
A tool to load env files into the environment
(Pseudo-)Example:
Dependencies
~425KB