#[doc = crate::_tags!(data word)]
#[doc = crate::_doc_meta!{location("data")}]
pub trait Word: Copy + Eq {
type Repr: Copy + Eq;
fn raw(self) -> Self::Repr;
fn from_raw(raw: Self::Repr) -> Self;
}
#[doc = crate::_tags!(data word construction)]
#[doc = crate::_doc_meta!{location("data")}]
#[macro_export]
#[cfg_attr(cargo_primary_package, doc(hidden))]
macro_rules! word {
(
$(#[$meta:meta])*
$vis:vis struct $name:ident($repr:ty);
) => {
$(#[$meta])*
#[repr(transparent)]
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
$vis struct $name($repr);
impl $name {
#[must_use] #[inline(always)]
pub const fn from_raw(raw: $repr) -> Self { Self(raw) }
#[must_use] #[inline(always)]
pub const fn raw(self) -> $repr { self.0 }
}
impl $crate::Word for $name {
type Repr = $repr;
#[inline(always)]
fn raw(self) -> Self::Repr { self.raw() }
#[inline(always)]
fn from_raw(raw: Self::Repr) -> Self { Self::from_raw(raw) }
}
};
}
pub use word;