You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
840 B

//! Helper functions & types
use super::*;
/// Like PhantomData but for a lifetime. Essentially PhantomData &'a ()
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Default, Copy)]
#[repr(transparent)]
pub struct PhantomLifetime<'a>(std::marker::PhantomData<&'a ()>);
impl<'a> PhantomLifetime<'a>
{
#[inline(always)]
pub const fn new() -> Self { Self (std::marker::PhantomData) }
}
unsafe impl<'a> Send for PhantomLifetime<'a>{}
unsafe impl<'a> Sync for PhantomLifetime<'a>{}
impl<'a> private::Sealed for PhantomLifetime<'a>{}
#[inline(always)]
pub unsafe fn address_eq_overlap<'t, 'u, T, U>(a: &'t T, b: &'u U) -> bool
{
std::ptr::eq(a as *const _, b as *const _ as *const T)
}
#[inline(always)]
pub fn address_eq<'a, 'b, T: ?Sized>(a: &'a T, b: &'b T) -> bool
{
std::ptr::eq(a as *const _, b as *const _)
}