use crate::Pin;
#[doc = crate::_tags!(uid allocation)]
#[doc = crate::_doc_location!("data/id")]
#[doc = crate::_doc!(vendor: "object-id")]
pub struct IdPin<'a> {
inner: Pin<&'a mut u8>,
}
impl<'a> IdPin<'a> {
pub fn new(data: &'a mut u8) -> Self {
let inner = Pin::new(data);
Self { inner }
}
pub fn as_usize(&self) -> usize {
(&raw const *self.inner).addr()
}
}
mod impl_traits {
use crate::{IdPin, Ordering, Ptr, impl_trait};
impl_trait![fmt::Debug for IdPin['a]['a] |self, f| write!(f, "{}", self.as_usize())];
impl_trait![Hash for IdPin['a]['a] |self, s| self.as_usize().hash(s)];
impl Eq for IdPin<'_> {}
impl PartialEq for IdPin<'_> {
fn eq(&self, other: &Self) -> bool {
Ptr::eq(&*self.inner, &*other.inner)
}
}
impl PartialOrd for IdPin<'_> {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}
impl Ord for IdPin<'_> {
fn cmp(&self, other: &Self) -> Ordering {
self.as_usize().cmp(&other.as_usize())
}
}
}