diff options
Diffstat (limited to 'src/source.rs')
-rw-r--r-- | src/source.rs | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/source.rs b/src/source.rs index dc5f3b5..bf2ed87 100644 --- a/src/source.rs +++ b/src/source.rs @@ -17,18 +17,22 @@ pub trait Source: Debug { fn collect_to(&self, cache: &mut Value) -> Result<()> { self.collect()? .iter() - .for_each(|(key, val)| match path::Expression::from_str(key) { - // Set using the path - Ok(expr) => expr.set(cache, val.clone()), - - // Set diretly anyway - _ => path::Expression::Identifier(key.clone()).set(cache, val.clone()), - }); + .for_each(|(key, val)| set_value(cache, key, val)); Ok(()) } } +fn set_value(cache: &mut Value, key: &String, value: &Value) { + match path::Expression::from_str(key) { + // Set using the path + Ok(expr) => expr.set(cache, value.clone()), + + // Set diretly anyway + _ => path::Expression::Identifier(key.clone()).set(cache, value.clone()), + } +} + impl Clone for Box<dyn Source + Send + Sync> { fn clone(&self) -> Box<dyn Source + Send + Sync> { self.clone_into_box() |