use std::{
mem::{transmute_copy, ManuallyDrop},
ops::Deref,
};
use crate::Atom;
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct FastAtom(ManuallyDrop<Atom>);
impl FastAtom {
#[inline]
pub unsafe fn new(atom: &Atom) -> Self {
Self(ManuallyDrop::new(transmute_copy(atom)))
}
}
impl Deref for FastAtom {
type Target = Atom;
#[inline]
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl Clone for FastAtom {
#[inline]
fn clone(&self) -> Self {
unsafe { Self::new(&self.0) }
}
}
impl PartialEq<Atom> for FastAtom {
#[inline]
fn eq(&self, other: &Atom) -> bool {
*self.0 == *other
}
}