#environment #env #dotenv #settings #config

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

#2062 in Procedural macros

Download history 65/week @ 2022-12-01 89/week @ 2022-12-08 66/week @ 2022-12-15 32/week @ 2022-12-22 24/week @ 2022-12-29 29/week @ 2023-01-05 72/week @ 2023-01-12 184/week @ 2023-01-19 263/week @ 2023-01-26 126/week @ 2023-02-02 31/week @ 2023-02-09 69/week @ 2023-02-16 138/week @ 2023-02-23 24/week @ 2023-03-02 51/week @ 2023-03-09 42/week @ 2023-03-16

265 downloads per month

MIT license

3KB

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