@@ -5,6 +5,7 @@ use crate::map::Map;
5
5
use crate :: source:: Source ;
6
6
use crate :: value:: { Value , ValueKind } ;
7
7
8
+ #[ cfg( feature = "convert-case" ) ]
8
9
use convert_case:: { Case , Casing } ;
9
10
10
11
/// An environment source collects a dictionary of environment variables values into a hierarchical
@@ -34,6 +35,7 @@ pub struct Environment {
34
35
/// Optional directive to translate collected keys into a form that matches what serializers
35
36
/// that the configuration would expect. For example if you have the `kebab-case` attribute
36
37
/// for your serde config types, you may want to pass Case::Kebab here.
38
+ #[ cfg( feature = "convert-case" ) ]
37
39
convert_case : Option < convert_case:: Case > ,
38
40
39
41
/// Optional character sequence that separates each env value into a vector. only works when try_parsing is set to true
@@ -106,10 +108,12 @@ impl Environment {
106
108
self
107
109
}
108
110
111
+ #[ cfg( feature = "convert-case" ) ]
109
112
pub fn with_convert_case ( tt : Case ) -> Self {
110
113
Self :: default ( ) . convert_case ( tt)
111
114
}
112
115
116
+ #[ cfg( feature = "convert-case" ) ]
113
117
pub fn convert_case ( mut self , tt : Case ) -> Self {
114
118
self . convert_case = Some ( tt) ;
115
119
self
@@ -180,6 +184,7 @@ impl Source for Environment {
180
184
let uri: String = "the environment" . into ( ) ;
181
185
182
186
let separator = self . separator . as_deref ( ) . unwrap_or ( "" ) ;
187
+ #[ cfg( feature = "convert-case" ) ]
183
188
let convert_case = & self . convert_case ;
184
189
let prefix_separator = match ( self . prefix_separator . as_deref ( ) , self . separator . as_deref ( ) ) {
185
190
( Some ( pre) , _) => pre,
@@ -218,6 +223,8 @@ impl Source for Environment {
218
223
if !separator. is_empty ( ) {
219
224
key = key. replace ( separator, "." ) ;
220
225
}
226
+
227
+ #[ cfg( feature = "convert-case" ) ]
221
228
if let Some ( convert_case) = convert_case {
222
229
key = key. to_case ( * convert_case) ;
223
230
}
0 commit comments