pub unsafe trait TempReprMutChk: TempReprMut {
type SwapChkData: PartialEq;
// Required method
fn swap_chk_data(&self) -> Self::SwapChkData;
}Expand description
An extension of TempReprMut that allows non-pinned mutable references to be passed to safe
client code.
§Safety
TempReprMutChk::swap_chk_data must be implemented in such a way that a call to
core::mem::swap is either detectable by calling swap_chk_data before and after and
comparing the result via the PartialEq implementation, or is harmless, in the following
sense:
Whenever a swapping operation is not detected by comparing the result of swap_chk_data,
the swapped instances must be interchangeable in terms of all safety conditions of TempRepr
and TempReprMut.
In particular, in all specific points, undefined behavior must also be avoided when the
condition “'a: 'b” is weakened to “'c: 'b for some 'c where the result of
swap_chk_data was equal.
Required Associated Types§
type SwapChkData: PartialEq
Required Methods§
Sourcefn swap_chk_data(&self) -> Self::SwapChkData
fn swap_chk_data(&self) -> Self::SwapChkData
Obtains an object (usually a copy of the internal state of self) that can be used to check
whether self was swapped with another instance of Self in such a way that the safety
rules of TempReprMutChk are violated.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.