Crate envint

Crate envint 

Source
Expand description

§envint

A quick & dirty proc-macro to parse env variables into integers for compile-time configuration.

§Installation

$ cargo add envint

§Usage:

Call the macro with first argument being the env variable name, and second - default value, if env variable couldn’t be found.

// Define env variable `SIZE` somewhere in project,
// for example in `.cargo/config.toml` `[env]` section
const SIZE: usize = envint::envint!("SIZE", 10);

TODO: Check if this works if variable isn’t defined in .cargo/config.toml Make default optional Don’t be lazy & return Literal instead of ugly format!() with a 100 .unwrap() calls

Macros§

envint