[−][src]Function pre::std::ptr::swap
pub unsafe fn swap<T>(x: *mut T, y: *mut T)
std::ptr::swap
with preconditions.
This function behaves exactly like std::ptr::swap
, but also has preconditions checked by pre
.
You should also read the Safety section on the documentation of std::ptr::swap
.
This function has preconditions
This function has the following preconditions generated by pre
attributes:
- the pointer
x
must be valid for reads and writes - the pointer
y
must be valid for reads and writes - the pointer
x
must have a proper alignment for its type - the pointer
y
must have a proper alignment for its type
To call the function you need to assure
that the preconditions hold:
ⓘThis example is not tested
#[assure( valid_ptr(x, r+w), reason = "<specify the reason why you can assure this here>" )] #[assure( valid_ptr(y, r+w), reason = "<specify the reason why you can assure this here>" )] #[assure( proper_align(x), reason = "<specify the reason why you can assure this here>" )] #[assure( proper_align(y), reason = "<specify the reason why you can assure this here>" )] swap(/* parameters omitted */);