2 stable releases

1.1.0 Sep 3, 2024
1.0.0 Mar 25, 2023

#243 in Procedural macros

Download history 262/week @ 2024-08-16 233/week @ 2024-08-23 275/week @ 2024-08-30 199/week @ 2024-09-06 255/week @ 2024-09-13 330/week @ 2024-09-20 492/week @ 2024-09-27 267/week @ 2024-10-04 377/week @ 2024-10-11 236/week @ 2024-10-18 320/week @ 2024-10-25 374/week @ 2024-11-01 280/week @ 2024-11-08 296/week @ 2024-11-15 2519/week @ 2024-11-22 307/week @ 2024-11-29

3,466 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