Crates.io | envro |
lib.rs | envro |
version | 0.3.3 |
source | src |
created_at | 2024-02-27 17:39:50.081542 |
updated_at | 2024-06-12 13:28:14.090716 |
description | A crate to load environment variables from a .env file into the process environment variables |
homepage | |
repository | |
max_upload_size | |
id | 1155298 |
size | 15,096 |
A crate to load environment variables from a .env file into the process environment variables
cargo add envro
use std::env;
use envro::*;
fn main() {
let env_file = env::current_dir().unwrap().join(".env-sample");
// load env vars and return them
let env_vars = load_dotenv(&env_file).unwrap();
println!("---");
println!(">> vars from .env file");
println!("{:#?}", &env_vars);
// load env vars into env::vars
load_dotenv_in_env_vars(&env_file).unwrap();
println!("---");
println!(">> from env::vars()");
for (key, value) in env::vars() {
if !env_vars.contains_key(&key) {
continue;
}
println!("{key}: {value}");
}
}
cargo test
MIT License
Copyright (c) 2024 Simone Sanfratello
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.