Struct write_only::WriteOnlyRef [−][src]
pub struct WriteOnlyRef<'a, T: 'a> { /* fields omitted */ }
Expand description
A write-only reference with dropping non-volatile write access.
Implementations
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.