//! Permutations of `PartialEq` between `Ck`, `Check`, `str`, and `String`. use crate::{Check, Ck, Invariant}; // `Check`s don't need to have the same backing storage to be equal. impl<'a, I, B1, B2> PartialEq> for &'a Check where I: Invariant, B1: AsRef, B2: AsRef, { fn eq(&self, other: &Check) -> bool { self.as_str() == other.as_str() } } impl<'a, I, B1, B2> PartialEq<&'a Check> for Check where I: Invariant, B1: AsRef, B2: AsRef, { fn eq(&self, other: &&'a Check) -> bool { self.as_str() == other.as_str() } } macro_rules! impl_partial_eq { ( $a:ty = $b:ty) => { impl PartialEq<$a> for $b { fn eq(&self, other: &$a) -> bool { AsRef::::as_ref(self) == AsRef::::as_ref(other) } } }; ( $a:ty = $b:ty) => { impl> PartialEq<$a> for $b { fn eq(&self, other: &$a) -> bool { AsRef::::as_ref(self) == AsRef::::as_ref(other) } } }; (<$lt:lifetime, I> $a:ty = $b:ty) => { impl<$lt, I: Invariant> PartialEq<$a> for $b { fn eq(&self, other: &$a) -> bool { AsRef::::as_ref(self) == AsRef::::as_ref(other) } } }; (<$lt:lifetime, I, B> $a:ty = $b:ty) => { impl<$lt, I: Invariant, B: AsRef> PartialEq<$a> for $b { fn eq(&self, other: &$a) -> bool { AsRef::::as_ref(self) == AsRef::::as_ref(other) } } }; } impl_partial_eq!(<'a, I> Ck = &'a Ck); impl_partial_eq!(<'a, I> &'a Ck = Ck); impl_partial_eq!( Ck = Check); impl_partial_eq!( Check = Ck); impl_partial_eq!(<'a, I, B> &'a Ck = Check); impl_partial_eq!(<'a, I, B> Check = &'a Ck); impl_partial_eq!(<'a, I, B> Ck = &'a Check); impl_partial_eq!(<'a, I, B> &'a Check = Ck); impl_partial_eq!( str = Check); impl_partial_eq!( Check = str); impl_partial_eq!(<'a, I, B> &'a str = Check); impl_partial_eq!(<'a, I, B> Check = &'a str); impl_partial_eq!(<'a, I, B> str = &'a Check); impl_partial_eq!(<'a, I, B> &'a Check = str); impl_partial_eq!( String = Check); impl_partial_eq!( Check = String); impl_partial_eq!(<'a, I, B> &'a String = Check); impl_partial_eq!(<'a, I, B> Check = &'a String); impl_partial_eq!(<'a, I, B> String = &'a Check); impl_partial_eq!(<'a, I, B> &'a Check = String); impl_partial_eq!( str = Ck); impl_partial_eq!( Ck = str); impl_partial_eq!(<'a, I> &'a str = Ck); impl_partial_eq!(<'a, I> Ck = &'a str); impl_partial_eq!(<'a, I> str = &'a Ck); impl_partial_eq!(<'a, I> &'a Ck = str); impl_partial_eq!( String = Ck); impl_partial_eq!( Ck = String); impl_partial_eq!(<'a, I> &'a String = Ck); impl_partial_eq!(<'a, I> Ck = &'a String); impl_partial_eq!(<'a, I> String = &'a Ck); impl_partial_eq!(<'a, I> &'a Ck = String);