#env #dotenv #env-file #compile-time #settings #config #proc-macro

macro load-dotenv

This is a small procedural macro to load your .env file at compile time

3 releases

0.1.2 Jan 4, 2021
0.1.1 Feb 15, 2019
0.1.0 Feb 15, 2019

#67 in #dotenv

Download history 93/week @ 2024-11-17 63/week @ 2024-11-24 71/week @ 2024-12-01 166/week @ 2024-12-08 128/week @ 2024-12-15 98/week @ 2024-12-22 65/week @ 2024-12-29 137/week @ 2025-01-05 185/week @ 2025-01-12 181/week @ 2025-01-19 73/week @ 2025-01-26 176/week @ 2025-02-02 211/week @ 2025-02-09 105/week @ 2025-02-16 188/week @ 2025-02-23 125/week @ 2025-03-02

659 downloads per month

MIT license

4KB

load-dotenv

This is a small procedural macro to load your .env file at compile time. That way you can use std::env! to load environment variables and fail the build if a variable is missing.

All it does is call the dotenv crate.

Example

.env file:

KEY=value

Rust:

use load_dotenv::load_dotenv;

load_dotenv!();

fn main() {
    assert_eq!("value", env!("KEY"));
}

License: MIT


lib.rs:

This is a small procedural macro to load your .env file at compile time. That way you can use std::env! to load environment variables and fail the build if a variable is missing.

All it does is call the dotenv crate.

Example

.env file:

KEY=value

Rust:

use load_dotenv::load_dotenv;

load_dotenv!();

fn main() {
    assert_eq!("value", env!("KEY"));
}

Dependencies

~34KB