use crate::pt;
use std::cmp::Ordering;
macro_rules! impl_with_cast {
($($t:ty),+) => {
$(
impl $t {
#[inline]
const fn as_discriminant(&self) -> &u8 {
unsafe { &*(self as *const Self as *const u8) }
}
}
impl PartialOrd for $t {
#[inline]
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}
impl Ord for $t {
#[inline]
fn cmp(&self, other: &Self) -> Ordering {
Ord::cmp(self.as_discriminant(), other.as_discriminant())
}
}
)+
};
}
impl_with_cast!(pt::Visibility, pt::VariableAttribute, pt::FunctionAttribute);