From 4f9299b4639802e05e1cb27d8eb40305ff8e110e Mon Sep 17 00:00:00 2001 From: Melody Horn Date: Mon, 11 Nov 2024 17:15:08 -0700 Subject: implement rule-specific macros for targets --- src/makefile/macro.rs | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) (limited to 'src/makefile/macro.rs') 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), AllBut(HashSet), @@ -73,7 +73,7 @@ impl ExportConfig { } } -#[derive(Clone, Debug)] +#[derive(Clone, Debug, PartialEq, Eq)] pub struct Set { pub data: HashMap, #[cfg(feature = "full")] @@ -128,13 +128,9 @@ impl Set { self.data.insert(name, r#macro); } - pub fn extend( - &mut self, - other: HashMap, - #[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")] -- cgit v1.2.3