diff options
Diffstat (limited to 'src/makefile/macro.rs')
-rw-r--r-- | src/makefile/macro.rs | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/makefile/macro.rs b/src/makefile/macro.rs index 5e7ea9c..65a87d1 100644 --- a/src/makefile/macro.rs +++ b/src/makefile/macro.rs @@ -36,7 +36,7 @@ pub trait LookupInternal: for<'a> Fn(&'a str) -> Result<String> {} impl<F: for<'a> Fn(&'a str) -> Result<String>> LookupInternal for F {} #[cfg(feature = "full")] -#[derive(Clone)] +#[derive(Clone, Debug)] pub enum ExportConfig { Only(HashSet<String>), AllBut(HashSet<String>), @@ -183,7 +183,21 @@ impl<'parent, 'lookup> Set<'parent, 'lookup> { .or_else(|| self.parent.and_then(|p| p.get(name).cloned())) } - pub fn extend(&mut self, other: HashMap<String, Macro>) { + pub fn extend(&mut self, other: HashMap<String, Macro>, other_exports: ExportConfig) { + match (&mut self.exported, other_exports) { + (ExportConfig::Only(se), ExportConfig::Only(oe)) => { + se.extend(oe); + } + (ExportConfig::AllBut(sne), ExportConfig::AllBut(one)) => { + sne.extend(one); + } + (ExportConfig::Only(se), ExportConfig::AllBut(one)) => { + se.extend(other.keys().cloned().filter(|name| !one.contains(name))); + } + (ExportConfig::AllBut(sne), ExportConfig::Only(oe)) => { + sne.extend(other.keys().cloned().filter(|name| !oe.contains(name))); + } + } self.data.extend(other); } |