Skip to content

Commit bc06e5e

Browse files
committed
convert-case: fix for building with this feature excluded
1 parent f8e577f commit bc06e5e

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/env.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use crate::map::Map;
55
use crate::source::Source;
66
use crate::value::{Value, ValueKind};
77

8+
#[cfg(feature = "convert-case")]
89
use convert_case::{Case, Casing};
910

1011
/// An environment source collects a dictionary of environment variables values into a hierarchical
@@ -34,6 +35,7 @@ pub struct Environment {
3435
/// Optional directive to translate collected keys into a form that matches what serializers
3536
/// that the configuration would expect. For example if you have the `kebab-case` attribute
3637
/// for your serde config types, you may want to pass Case::Kebab here.
38+
#[cfg(feature = "convert-case")]
3739
convert_case: Option<convert_case::Case>,
3840

3941
/// 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 {
106108
self
107109
}
108110

111+
#[cfg(feature = "convert-case")]
109112
pub fn with_convert_case(tt: Case) -> Self {
110113
Self::default().convert_case(tt)
111114
}
112115

116+
#[cfg(feature = "convert-case")]
113117
pub fn convert_case(mut self, tt: Case) -> Self {
114118
self.convert_case = Some(tt);
115119
self
@@ -180,6 +184,7 @@ impl Source for Environment {
180184
let uri: String = "the environment".into();
181185

182186
let separator = self.separator.as_deref().unwrap_or("");
187+
#[cfg(feature = "convert-case")]
183188
let convert_case = &self.convert_case;
184189
let prefix_separator = match (self.prefix_separator.as_deref(), self.separator.as_deref()) {
185190
(Some(pre), _) => pre,
@@ -218,6 +223,8 @@ impl Source for Environment {
218223
if !separator.is_empty() {
219224
key = key.replace(separator, ".");
220225
}
226+
227+
#[cfg(feature = "convert-case")]
221228
if let Some(convert_case) = convert_case {
222229
key = key.to_case(*convert_case);
223230
}

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,5 @@ pub use crate::source::{AsyncSource, Source};
4444
pub use crate::value::{Value, ValueKind};
4545

4646
// Re-export
47+
#[cfg(feature = "convert-case")]
4748
pub use convert_case::Case;

0 commit comments

Comments
 (0)