summaryrefslogtreecommitdiffstats
path: root/src/env.rs
diff options
context:
space:
mode:
authorRyan Leckey <ryan@launchbadge.com>2018-09-25 23:45:11 -0700
committerRyan Leckey <ryan@launchbadge.com>2018-09-25 23:45:11 -0700
commit8cfde7d3c6767e39e4ca35f99f453f810f6d1926 (patch)
tree7d2e4ae3734c9c11d5d5b94bf399dfd5da3149e4 /src/env.rs
parenta1cd868c0224f16d921a25f04cbc39cb03a5471d (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.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/env.rs b/src/env.rs
index d570932..ce67069 100644
--- a/src/env.rs
+++ b/src/env.rs
@@ -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;
}