-
-
Save tomjakubowski/6631d993aaba7339f77a to your computer and use it in GitHub Desktop.
Shared via Rust Playground
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
macro_rules! as_item { | |
($i:item) => {$i}; | |
} | |
macro_rules! impl_partial_eq { | |
([$($lt:tt)*] $lhs:ty, $rhs:ty) => { | |
as_item! { | |
impl<$($lt)*> PartialEq<$rhs> for $lhs { | |
fn eq(&self, other: &$rhs) -> bool { | |
// common implementation of PartialEq goes here | |
panic!() | |
} | |
} | |
} | |
}; | |
} | |
struct Foo<'a> { x: &'a i32 } | |
impl_partial_eq!(['a] Foo<'a>, Foo<'a>); | |
fn main() {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment