pub const unsafe fn replace<T>(dst: *mut T, src: T) -> T
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:
-
dst
must be valid for both reads and writes. -
dst
must be properly aligned. -
dst
must point to a properly initialized value of typeT
.
Note that even if T
has size 0
, the pointer must be properly aligned.