Struct pinned_aliasable::Aliasable
source · [−]pub struct Aliasable<T> { /* private fields */ }
Expand description
An unboxed aliasable value.
Implementations
sourceimpl<T> Aliasable<T>
impl<T> Aliasable<T>
sourcepub fn get(self: Pin<&Self>) -> &T
pub fn get(self: Pin<&Self>) -> &T
Get a shared reference to the value inside the Aliasable
.
This method takes Pin
<&Self>
instead of &self
to enforce that all parent containers
are !
Unpin
, and thus won’t be annotated with noalias
.
This crate intentionally does not provide a method to get an &mut T
, because the value
may be shared. To obtain an &mut T
you should use an interior mutable container such as a
mutex or UnsafeCell
.
sourcepub unsafe fn get_extended<'a>(self: Pin<&Self>) -> &'a T
pub unsafe fn get_extended<'a>(self: Pin<&Self>) -> &'a T
Get a shared reference to the value inside the Aliasable
with an extended lifetime.
Safety
The reference must not be held for longer than the Aliasable
exists.
sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Consume the Aliasable
, returning its inner value.
If get
has already been called and the type is now pinned, obtaining the owned
Aliasable<T>
required to call this function requires breaking the pinning guarantee (as
the Aliasable<T>
is moved). However, this is sound as long as the Aliasable<T>
isn’t
actually aliased at that point in time.
Trait Implementations
Auto Trait Implementations
impl<T> RefUnwindSafe for Aliasable<T> where
T: RefUnwindSafe,
impl<T> Send for Aliasable<T> where
T: Send,
impl<T> Sync for Aliasable<T> where
T: Sync,
impl<T> !Unpin for Aliasable<T>
impl<T> UnwindSafe for Aliasable<T> where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more