pub trait AccessAs {
// Required methods
fn ref_as<T>(&self) -> Self::Guard<'_>
where Self: IGuardRef<T>,
T: ?Sized;
fn mut_as<T>(&mut self) -> Self::GuardMut<'_>
where Self: IGuardMut<T>,
T: ?Sized;
}
Expand description
Provides access to a value as if it were of another type.
This is done by the following process:
- memcopy
self
intocopy
- convert
copy
intotarget: ManuallyDrop<Target>
- provide a guard that can
Deref
orDerefMut
intotarget
- upon dropping the mutable guard, convert
target
and assingtarget
toself
This is always safe for non-self-referencial types.
Required Methods§
Object Safety§
This trait is not object safe.