pub const unsafe fn replace<T>(dst: *mut T, src: T) -> TThis item is validated for IEC 61508 (SIL 2) and ISO 26262 (ASIL B).
Expand description
Moves src into the pointed dst, returning the previous dst value.
Neither value is dropped.
This function is semantically equivalent to mem::replace except that it
operates on raw pointers instead of references. When references are
available, mem::replace should be preferred.
§Safety
Behavior is undefined if any of the following conditions are violated:
-
dstmust be valid for both reads and writes orTmust be a ZST. -
dstmust be properly aligned. -
dstmust point to a properly initialized value of typeT.
Note that even if T has size 0, the pointer must be properly aligned.