pub struct WriteOnlyRef<'a, T: 'a> { /* private fields */ }
Expand description
A write-only reference with dropping non-volatile write access.
Implementations§
Source§impl<'a, T: 'a> WriteOnlyRef<'a, T>
impl<'a, T: 'a> WriteOnlyRef<'a, T>
Sourcepub unsafe fn from_ptr(data: *mut T) -> Self
pub unsafe fn from_ptr(data: *mut T) -> Self
Forms a write-only reference from a pointer.
§Safety
Behavior is undefined if any of the following conditions are violated:
-
data
must be valid for reads forlen * mem::size_of::<T>()
many bytes, and it must be properly aligned. This means in particular:data
must be non-null and aligned. One reason for this is that enum layout optimizations may rely on references being aligned and non-null to distinguish them from other data.
-
The memory referenced by the returned reference must not be mutated for the duration of lifetime
'a
, except inside anUnsafeCell
.
§Caveat
The lifetime for the returned reference is inferred from its usage. To prevent accidental misuse, it’s suggested to tie the lifetime to whichever source lifetime is safe in the context, such as by providing a helper function taking the lifetime of a host guard for the reference, or by explicit annotation.
Trait Implementations§
Source§impl<'a, T: 'a> From<&'a mut T> for WriteOnlyRef<'a, T>
impl<'a, T: 'a> From<&'a mut T> for WriteOnlyRef<'a, T>
Source§impl<'a, T: 'a> Put<T> for WriteOnlyRef<'a, T>
impl<'a, T: 'a> Put<T> for WriteOnlyRef<'a, T>
Auto Trait Implementations§
impl<'a, T> Freeze for WriteOnlyRef<'a, T>
impl<'a, T> RefUnwindSafe for WriteOnlyRef<'a, T>where
T: RefUnwindSafe,
impl<'a, T> !Send for WriteOnlyRef<'a, T>
impl<'a, T> !Sync for WriteOnlyRef<'a, T>
impl<'a, T> Unpin for WriteOnlyRef<'a, T>
impl<'a, T> UnwindSafe for WriteOnlyRef<'a, T>where
T: RefUnwindSafe,
Blanket Implementations§
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
Mutably borrows from an owned value. Read more