#[repr(transparent)]pub struct RawAttachmentMut<'a> {
ptr: NonNull<AttachmentData<Erased>>,
_marker: PhantomData<&'a mut AttachmentData<Erased>>,
}Expand description
A mutable lifetime-bound pointer to an AttachmentData that is guaranteed
to be the sole mutable pointer to an initialized instance of an
AttachmentData<A> for some specific A, though we do not know which
actual A it is.
We cannot use a &'a mut AttachmentData<A> directly, because that would
require us to know the actual type of the attachment, which we do not.
Fields§
§ptr: NonNull<AttachmentData<Erased>>Pointer to the inner attachment data
§Safety
The following safety invariants are guaranteed to be upheld as long as this struct exists:
- The pointer must have been created from a
Box<AttachmentData<A>>for someAusingBox::into_raw. - The pointer will point to the same
AttachmentData<A>for the entire lifetime of this object. - This pointer represents exclusive mutable access to the
AttachmentDatafor the lifetime'awith the same semantics as a&'a mut AttachmentData<C>.
_marker: PhantomData<&'a mut AttachmentData<Erased>>Marker to tell the compiler that we should
behave the same as a &'a mut AttachmentData<Erased>
Implementations§
Source§impl<'a> RawAttachmentMut<'a>
impl<'a> RawAttachmentMut<'a>
Sourcepub unsafe fn into_attachment_downcast_unchecked<A: 'static>(self) -> &'a mut A
pub unsafe fn into_attachment_downcast_unchecked<A: 'static>(self) -> &'a mut A
Accesses the inner attachment of the AttachmentData instance as a
reference to the specified type.
§Safety
The caller must ensure:
- The type
Amatches the actual attachment type stored in theAttachmentData.
Source§impl<'a> RawAttachmentMut<'a>
impl<'a> RawAttachmentMut<'a>
Sourcepub(super) unsafe fn cast_inner<A>(self) -> &'a mut AttachmentData<A>
pub(super) unsafe fn cast_inner<A>(self) -> &'a mut AttachmentData<A>
Casts the RawAttachmentMut to an AttachmentData<A> mutable
reference.
§Safety
The caller must ensure:
- The type
Amatches the actual attachment type stored in theAttachmentData.
Sourcepub fn reborrow<'b>(&'b mut self) -> RawAttachmentMut<'b>
pub fn reborrow<'b>(&'b mut self) -> RawAttachmentMut<'b>
Reborrows the mutable reference to the AttachmentData with a shorter
lifetime.
Sourcepub fn as_ref<'b: 'a>(&'b self) -> RawAttachmentRef<'b>
pub fn as_ref<'b: 'a>(&'b self) -> RawAttachmentRef<'b>
Returns a reference to the AttachmentData instance.
Sourcepub fn into_ref(self) -> RawAttachmentRef<'a>
pub fn into_ref(self) -> RawAttachmentRef<'a>
Consumes the mutable reference and returns an immutable one with the same lifetime.