Struct manually_boxed::NoAliasSingleton
source · #[non_exhaustive]pub struct NoAliasSingleton {}
Expand description
Singleton, used for compile-time alias checking
You’ll need one owned one of these, from
NoAliasSingleton::init()
.
Typically, instead of passing &mut NoAliasSingleton
to your own sub-functions,
you’ll pass TokenMut
(or TokenRef
,
which can be obtained (and copied)
with
IsTokenRef::token_ref
and
IsTokenMut::token_mut
.
Those token types are zero-sized types, so they incur no runtime cost, even if the compiler can’t figure out that they aren’t ever used.
(NoAliasSingleton
is a ZST too,
but of course &mut NoAliasSingleton
isn’t.)
Implementations§
source§impl NoAliasSingleton
impl NoAliasSingleton
sourcepub unsafe fn init() -> Self
pub unsafe fn init() -> Self
Initialises, by creating the singleton for alias checking
§SAFETY
There must be only one NoAliasSingleton
used with each Ptr
.
That is, it is unsound to use the same Ptr
(or any copy of it)
with TokenMut
es derived from
two (or more) different NoAliasSingleton
s.
The easiest way to do this is to have only one NoAliasSingleton
.
If this rule is violated, borrow
and borrow_mut
can be instant-UB.
Trait Implementations§
source§impl Debug for NoAliasSingleton
impl Debug for NoAliasSingleton
source§impl<'a> IsTokenMut<'a> for &'a mut NoAliasSingleton
impl<'a> IsTokenMut<'a> for &'a mut NoAliasSingleton
source§fn token_mut<'r>(self) -> TokenMut<'r>where
'a: 'r,
fn token_mut<'r>(self) -> TokenMut<'r>where
'a: 'r,
source§fn as_mut<'r, 's: 'r>(&'s mut self) -> TokenMut<'r>where
'a: 'r,
fn as_mut<'r, 's: 'r>(&'s mut self) -> TokenMut<'r>where
'a: 'r,
source§fn multi_static<'r>(self) -> MultiStatic<'r, ()>where
'a: 'r,
fn multi_static<'r>(self) -> MultiStatic<'r, ()>where
'a: 'r,
Ptr
Read moresource§fn multi_dynamic<'r>(self) -> MultiDynamic<'r>where
'a: 'r,
fn multi_dynamic<'r>(self) -> MultiDynamic<'r>where
'a: 'r,
Ptr
with dynamic runtime checking Read more