Created
January 13, 2022 09:34
-
-
Save dgellow/1fa4955c3bbcc1cfeb49c36183198fc6 to your computer and use it in GitHub Desktop.
Rust macro implementing BitOr trait for multiple struct
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub struct ClassStyle(pub WNDCLASS_STYLES); | |
pub struct WindowStyle(pub WINDOW_STYLE); | |
macro_rules! impl_ops_for_all { | |
($($t:ty),+) => { | |
$(impl std::ops::BitOr for $t { | |
type Output = Self; | |
fn bitor(self, rhs: Self) -> Self::Output { | |
Self(self.0 | rhs.0) | |
} | |
})* | |
} | |
} | |
impl_ops_for_all!(class_style::Type, style::Type); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment