rustdotenv 0.1.2

A tool to load env files into the environment
Documentation
  • Coverage
  • 100%
    4 out of 4 items documented0 out of 3 items with examples
  • Size
  • Source code size: 4.45 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.06 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • nilpntr/rustdotenv
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • nilpntr

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())
    }
}