diff options
Diffstat (limited to 'src/makefile/macro.rs')
-rw-r--r-- | src/makefile/macro.rs | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/src/makefile/macro.rs b/src/makefile/macro.rs index b2a1510..3b472a3 100644 --- a/src/makefile/macro.rs +++ b/src/makefile/macro.rs @@ -14,7 +14,7 @@ use super::{ItemSource, TokenString}; #[cfg(feature = "full")] use eyre::Result; -#[derive(Debug, Clone)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct Macro { pub source: ItemSource, pub text: TokenString, @@ -23,7 +23,7 @@ pub struct Macro { } #[cfg(feature = "full")] -#[derive(Clone, Debug)] +#[derive(Clone, Debug, PartialEq, Eq)] pub enum ExportConfig { Only(HashSet<String>), AllBut(HashSet<String>), @@ -73,7 +73,7 @@ impl ExportConfig { } } -#[derive(Clone, Debug)] +#[derive(Clone, Debug, PartialEq, Eq)] pub struct Set { pub data: HashMap<String, Macro>, #[cfg(feature = "full")] @@ -128,13 +128,9 @@ impl Set { self.data.insert(name, r#macro); } - pub fn extend( - &mut self, - other: HashMap<String, Macro>, - #[cfg(feature = "full")] other_exports: ExportConfig, - ) { + pub fn extend(&mut self, other: Self) { #[cfg(feature = "full")] - match (&mut self.exported, other_exports) { + match (&mut self.exported, other.exported) { (ExportConfig::Only(se), ExportConfig::Only(oe)) => { se.extend(oe); } @@ -142,13 +138,25 @@ impl Set { sne.extend(one); } (ExportConfig::Only(se), ExportConfig::AllBut(one)) => { - se.extend(other.keys().filter(|name| !one.contains(*name)).cloned()); + se.extend( + other + .data + .keys() + .filter(|name| !one.contains(*name)) + .cloned(), + ); } (ExportConfig::AllBut(sne), ExportConfig::Only(oe)) => { - sne.extend(other.keys().filter(|name| !oe.contains(*name)).cloned()); + sne.extend( + other + .data + .keys() + .filter(|name| !oe.contains(*name)) + .cloned(), + ); } } - self.data.extend(other); + self.data.extend(other.data); } #[cfg(feature = "full")] |