Repository: mehcode/config-rs (rust)

Issue:
Environment::with_prefix() doesn't use custom separator.
At https://github.com/mehcode/config-rs/blob/master/src/env.rs#L81
```rust
        let prefix_pattern = match self.prefix {
            Some(ref prefix) => Some(prefix.clone() + "_"),
            _ => None,
        };
```
"_" is appended by default. Shouldn't the custom separator be appended if it exists instead?

Pull request description:
Fix custom separator for group prefixes
Closes #173

Patch provided by @lyuben-todorov in #173

Patch:
diff --git a/src/env.rs b/src/env.rs
index 79472ba..5fc299d 100644
--- a/src/env.rs
+++ b/src/env.rs
@@ -76,8 +76,16 @@ impl Source for Environment {
             _ => "",
         };
 
+        let group_separator = match self.separator {
+            Some(ref separator) => separator,
+            _ => "_",
+        };
+
         // Define a prefix pattern to test and exclude from keys
-        let prefix_pattern = self.prefix.as_ref().map(|prefix| prefix.clone() + "_");
+        let prefix_pattern = self
+            .prefix
+            .as_ref()
+            .map(|prefix| format!("{}{}", prefix.clone(), group_separator));
 
         for (key, value) in env::vars() {
             // Treat empty environment variables as unset


Test patch:
diff --git a/tests/env.rs b/tests/env.rs
index bb1a1ec..ffc0572 100644
--- a/tests/env.rs
+++ b/tests/env.rs
@@ -71,3 +71,14 @@ fn test_empty_value_is_ignored() {
 
     env::remove_var("C_A_B");
 }
+
+#[test]
+fn test_custom_separator_behavior() {
+    env::set_var("C.B.A", "abc");
+
+    let environment = Environment::with_prefix("C").separator(".");
+
+    assert!(environment.collect().unwrap().contains_key("b.a"));
+
+    env::remove_var("C.B.A");
+}