diff options
author | Ryan Leckey <ryan@launchbadge.com> | 2018-09-25 23:45:11 -0700 |
---|---|---|
committer | Ryan Leckey <ryan@launchbadge.com> | 2018-09-25 23:45:11 -0700 |
commit | 8cfde7d3c6767e39e4ca35f99f453f810f6d1926 (patch) | |
tree | 7d2e4ae3734c9c11d5d5b94bf399dfd5da3149e4 /src/env.rs | |
parent | a1cd868c0224f16d921a25f04cbc39cb03a5471d (diff) |
Use a build config on Environment instead of a feature flag for #78
Diffstat (limited to 'src/env.rs')
-rw-r--r-- | src/env.rs | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -19,6 +19,9 @@ pub struct Environment { /// Consider a nested configuration such as `redis.password`, a separator of `_` would allow /// an environment key of `REDIS_PASSWORD` to match. separator: Option<String>, + + /// Ignore empty env values (treat as unset). + ignore_empty: bool, } impl Environment { @@ -42,6 +45,11 @@ impl Environment { self.separator = Some(s.into()); self } + + pub fn ignore_empty(mut self, ignore: bool) -> Self { + self.ignore_empty = ignore; + self + } } impl Default for Environment { @@ -49,6 +57,7 @@ impl Default for Environment { Environment { prefix: None, separator: None, + ignore_empty: false, } } } @@ -75,7 +84,7 @@ impl Source for Environment { for (key, value) in env::vars() { // Treat empty environment variables as unset - if cfg!(feature = "ignore-empty-env-vars") && value == "" { + if self.ignore_empty && value == "" { continue; } |