pub struct Aliasable<T> { /* private fields */ }Expand description
An unboxed aliasable value.
Implementations§
Source§impl<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.