pub struct Seal<'a, T: ?Sized> { /* private fields */ }Expand description
A mutable reference which may not be moved or assigned.
A Seal restricts a mutable reference so that the referenced value cannot
be moved or assigned unless it is Unpin and NoUndef. These properties
allow the safe use of mutable archived values.
Unlike Pin, all fields of Sealed values are also sealed. There is no
notion of “structural sealing” as there is structural pinning. This has the
upside that a Seal can be uniformly destructured with munge, which is
the recommended replacement for Pin’s map_unchecked_mut function. Also
unlike Pin, Sealing a reference does not require upholding the invariant
that the sealed value is dropped before its backing memory is reused. This
means that creating a Seal from a mutable reference is completely safe to
do.
Implementations§
Source§impl<'a, T: ?Sized> Seal<'a, T>
impl<'a, T: ?Sized> Seal<'a, T>
Sourcepub fn unseal(self) -> &'a mut T
pub fn unseal(self) -> &'a mut T
Returns the underlying reference for types that implement NoUndef
and Unpin.
Sourcepub fn unseal_ref(self) -> &'a T
pub fn unseal_ref(self) -> &'a T
Returns the underlying reference as shared for types that implement
Portable.
Sourcepub unsafe fn unseal_unchecked(self) -> &'a mut T
pub unsafe fn unseal_unchecked(self) -> &'a mut T
Returns the underlying reference.
§Safety
The returned reference may not be moved unless T is Unpin.
Uninitialized bytes may not be written through the Seal.
Trait Implementations§
Source§impl<T: ?Sized> Destructure for Seal<'_, T>
impl<T: ?Sized> Destructure for Seal<'_, T>
Source§type Underlying = T
type Underlying = T
Source§type Destructuring = Borrow
type Destructuring = Borrow
Source§fn underlying(&mut self) -> *mut Self::Underlying
fn underlying(&mut self) -> *mut Self::Underlying
Source§impl<'a, T> IntoIterator for Seal<'a, ArchivedOption<T>>
impl<'a, T> IntoIterator for Seal<'a, ArchivedOption<T>>
Source§impl<'a, T: ?Sized, U: 'a + ?Sized> Restructure<U> for Seal<'a, T>
impl<'a, T: ?Sized, U: 'a + ?Sized> Restructure<U> for Seal<'a, T>
Source§type Restructured = Seal<'a, U>
type Restructured = Seal<'a, U>
Source§unsafe fn restructure(&self, ptr: *mut U) -> Self::Restructured
unsafe fn restructure(&self, ptr: *mut U) -> Self::Restructured
Auto Trait Implementations§
impl<'a, T> Freeze for Seal<'a, T>where
T: ?Sized,
impl<'a, T> RefUnwindSafe for Seal<'a, T>where
T: RefUnwindSafe + ?Sized,
impl<'a, T> Send for Seal<'a, T>
impl<'a, T> Sync for Seal<'a, T>
impl<'a, T> Unpin for Seal<'a, T>where
T: ?Sized,
impl<'a, T> UnsafeUnpin for Seal<'a, T>where
T: ?Sized,
impl<'a, T> !UnwindSafe for Seal<'a, T>
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.