2 stable releases

1.1.0 Sep 3, 2024
1.0.0 Mar 25, 2023

#245 in Procedural macros

Download history 100/week @ 2024-06-18 82/week @ 2024-06-25 133/week @ 2024-07-02 62/week @ 2024-07-09 44/week @ 2024-07-16 54/week @ 2024-07-23 158/week @ 2024-07-30 452/week @ 2024-08-06 234/week @ 2024-08-13 346/week @ 2024-08-20 141/week @ 2024-08-27 342/week @ 2024-09-03 208/week @ 2024-09-10 299/week @ 2024-09-17 295/week @ 2024-09-24 464/week @ 2024-10-01

1,316 downloads per month

MIT license

3KB

Needs environment variable

Skip code (such as a test) at compile time if an environment variable is undefined.

Example

some_test will not be compiled if SOMEENVIRONMENTVARIABLE is not defined:

use needs_env_var::*;

#[needs_env_var(SOMEENVIRONMENTVARIABLE)]
#[test]
fn some_test() {
    assert!(1 == 1);
}

// or if its specified value not matched
#[needs_env_var(SOMEENVIRONMENTVARIABLE = 1)]
#[test]
fn some_test() {
    assert!(1 == 1);
}


#[needs_env_var(SOMEENVIRONMENTVARIABLE=1)]
#[test]
fn some_test() {
    assert!(1 == 1);
}

Note: As needs_env_var is evaluated at compile time you need to force a re-compilation an environment variable is defined after compilation, e.g. with cargo clean.

No runtime deps