use crate::{algebraic_type::AlgebraicType, impl_deserialize, impl_serialize, meta_type::MetaType};
use std::fmt::Display;
#[derive(Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct AlgebraicTypeRef(
pub u32,
);
impl AlgebraicTypeRef {
pub const fn idx(self) -> usize {
self.0 as usize
}
}
impl_serialize!([] AlgebraicTypeRef, (self, ser) => self.0.serialize(ser));
impl_deserialize!([] AlgebraicTypeRef, de => u32::deserialize(de).map(Self));
impl Display for AlgebraicTypeRef {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "&{}", self.0)
}
}
impl MetaType for AlgebraicTypeRef {
fn meta_type() -> AlgebraicType {
AlgebraicType::U32
}
}