summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/source.rs15
1 files changed, 4 insertions, 11 deletions
diff --git a/src/source.rs b/src/source.rs
index 4d1ba53..8fb4ae3 100644
--- a/src/source.rs
+++ b/src/source.rs
@@ -14,22 +14,15 @@ pub trait Source: Debug {
fn collect(&self) -> Result<HashMap<String, Value>>;
fn collect_to(&self, cache: &mut Value) -> Result<()> {
- let props = match self.collect() {
- Ok(props) => props,
- Err(error) => {
- return Err(error);
- }
- };
-
- for (key, val) in &props {
- match path::Expression::from_str(key) {
+ 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()),
- }
- }
+ });
Ok(())
}