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.