wrath 0.1.0

A structured approach to accessing environment variables
Documentation
// https://github.com/rust-lang/rust-clippy/issues/11024
#![allow(clippy::tests_outside_test_module)]

/// An easy way to construct a map representing environment variables
macro_rules! env_map {
    ($($k:literal = $v:literal),* $(,)?) => {{
        use ::std::{collections::HashMap, ffi::OsString};

        #[allow(unused_mut)]
        let mut map = HashMap::<OsString, OsString>::new();

        $(
            map.insert(OsString::from($k), OsString::from($v));
        )*

        map
    }}
}

macro_rules! expect_msg {
    () => {
        "should be able to parse from environment variables"
    };
}

/// Load `T` from `env`, asserting the result, then panicking on failure
macro_rules! make_snapshot_test {
    ($t:ident, $env:expr $(,)?) => {{
        let x = $t::try_from($env);

        ::insta::with_settings!({
            omit_expression => true,
        }, {
            ::insta::assert_debug_snapshot!(x);
        });

        x.expect(expect_msg!());
    }}
}

mod default_fromstr_i32;
mod from_pathbuf;
mod fromstr_i32;
mod intostring;
mod many_fields;
mod option_fromstr_i32;

#[test]
fn macros() {
    let t = trybuild::TestCases::new();
    t.pass("tests/integrations/macros/pass/*.rs");
    t.compile_fail("tests/integrations/macros/compile_fail/*.rs");
}