diff options
author | Radosław Kot <rdkt13@gmail.com> | 2021-04-24 19:44:27 +0200 |
---|---|---|
committer | Radosław Kot <rdkt13@gmail.com> | 2021-05-08 17:43:16 +0200 |
commit | 98662dd899d4eaab5dc2da07d5bb658960b588a6 (patch) | |
tree | c7513c9038ee817c62e444ff02507bca2da363bc /src/source.rs | |
parent | 82d23c76a8637360e03c0b43d9a1c0c26d820d9f (diff) |
Modify tests to use both ConfigBuilder and Config
Diffstat (limited to 'src/source.rs')
-rw-r--r-- | src/source.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/source.rs b/src/source.rs index 2b0eb30..dc5f3b5 100644 --- a/src/source.rs +++ b/src/source.rs @@ -55,6 +55,26 @@ impl Source for Vec<Box<dyn Source + Send + Sync>> { } } +impl Source for [Box<dyn Source + Send + Sync>] { + fn clone_into_box(&self) -> Box<dyn Source + Send + Sync> { + Box::new(self.to_owned()) + } + + fn collect(&self) -> Result<HashMap<String, Value>> { + let mut cache: Value = HashMap::<String, Value>::new().into(); + + for source in self { + source.collect_to(&mut cache)?; + } + + if let ValueKind::Table(table) = cache.kind { + Ok(table) + } else { + unreachable!(); + } + } +} + impl<T> Source for Vec<T> where T: Source + Sync + Send, |