use std::{marker, mem};
use o3::base::marker::ThreadBound;
pub struct Anchor<'a> {
owner: marker::PhantomData<(&'a mut Anchor<'a>, ThreadBound)>,
}
impl Default for Anchor<'_> {
fn default() -> Self {
Self::new()
}
}
impl<'a> Anchor<'a> {
pub const fn new() -> Self {
Self {
owner: marker::PhantomData,
}
}
pub(in crate::driver) fn owner(self) -> marker::PhantomData<(&'a mut Self, ThreadBound)> {
self.owner
}
}
pub unsafe trait Root<'a> {
fn anchor(self) -> Anchor<'a>;
}
const _: () = {
assert!(mem::size_of::<Anchor<'static>>() == 0);
assert!(mem::align_of::<Anchor<'static>>() == 1);
assert!(mem::size_of::<marker::PhantomData<(&mut Anchor<'static>, ThreadBound)>>() == 0);
assert!(mem::align_of::<marker::PhantomData<(&mut Anchor<'static>, ThreadBound)>>() == 1);
};