Skip to content

Instantly share code, notes, and snippets.

@dgellow
Created January 13, 2022 09:34
Show Gist options
  • Save dgellow/1fa4955c3bbcc1cfeb49c36183198fc6 to your computer and use it in GitHub Desktop.
Save dgellow/1fa4955c3bbcc1cfeb49c36183198fc6 to your computer and use it in GitHub Desktop.
Rust macro implementing BitOr trait for multiple struct
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