Trait stabby::AccessAs

source ·
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 into copy
  • convert copy into target: ManuallyDrop<Target>
  • provide a guard that can Deref or DerefMut into target
  • upon dropping the mutable guard, convert target and assing target to self

This is always safe for non-self-referencial types.

Required Methods§

source

fn ref_as<T>(&self) -> Self::Guard<'_>
where Self: IGuardRef<T>, T: ?Sized,

Provides immutable access to a type as if it were its ABI-unstable equivalent.

source

fn mut_as<T>(&mut self) -> Self::GuardMut<'_>
where Self: IGuardMut<T>, T: ?Sized,

Provides mutable access to a type as if it were its ABI-unstable equivalent.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<Source> AccessAs for Source