#env-file #env #dotenv #environment #compile-time #settings #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

#53 in #dotenv

Download history 85/week @ 2024-03-13 99/week @ 2024-03-20 116/week @ 2024-03-27 121/week @ 2024-04-03 65/week @ 2024-04-10 84/week @ 2024-04-17 89/week @ 2024-04-24 95/week @ 2024-05-01 104/week @ 2024-05-08 100/week @ 2024-05-15 99/week @ 2024-05-22 94/week @ 2024-05-29 74/week @ 2024-06-05 62/week @ 2024-06-12 89/week @ 2024-06-19 65/week @ 2024-06-26

307 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