Skip to content

Commit

Permalink
change config methods to use lowercase keys
Browse files Browse the repository at this point in the history
  • Loading branch information
YounessBird committed Jul 14, 2022
1 parent d2ee90e commit 9671e62
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ impl Config {
where
T: Into<Value>,
{
self.defaults.insert(key.parse()?, value.into());
self.defaults
.insert(key.to_lowercase().as_str().parse()?, value.into());

#[allow(deprecated)]
self.refresh()
Expand All @@ -129,15 +130,16 @@ impl Config {
where
T: Into<Value>,
{
self.overrides.insert(key.parse()?, value.into());
self.overrides
.insert(key.to_lowercase().as_str().parse()?, value.into());

#[allow(deprecated)]
self.refresh()
}

#[deprecated(since = "0.12.0", note = "please use 'ConfigBuilder' instead")]
pub fn set_once(&mut self, key: &str, value: Value) -> Result<()> {
let expr: path::Expression = key.parse()?;
let expr: path::Expression = key.to_lowercase().as_str().parse()?;

// Traverse the cache using the path to (possibly) retrieve a value
if let Some(ref mut val) = expr.get_mut(&mut self.cache) {
Expand All @@ -149,6 +151,8 @@ impl Config {
}

pub fn get<'de, T: Deserialize<'de>>(&self, key: &str) -> Result<T> {
let k = key.to_lowercase();
let key = k.as_str();
// Parse the key into a path expression
let expr: path::Expression = key.parse()?;

Expand Down

0 comments on commit 9671e62

Please sign in to comment.