Function Subspace :: sus :: ptr :: copy
!std::is_const_v<T>
Copies count * size_of<T>()
bytes from src
to dst
. The source and
destination may overlap.
If the source and destination will never overlap,
copy_nonoverlapping
can be used instead.
copy
is semantically equivalent to
memmove
, but
with the argument order swapped.
Copying takes place as if the bytes were copied from src
to
a temporary array and then copied from the array to dst
.
The copy is “untyped” in the sense that data may be uninitialized or
otherwise violate the requirements of T
. The initialization state is
preserved exactly.
Panics
This function will panic if the number of bytes, count * size_of<T>()
,
overflows.
Safety
Behavior is undefined if any of the following conditions are violated:
src
must be valid for reads ofcount * size_of<T>()
bytes.dst
must be valid for writes ofcount * size_of<T>()
bytes.dst
must not have an overlapping object in its tail padding. Ifdst
is in an array, or was heap allocated, then this will always be satisfied.
copy
creates a bitwise copy of T
, regardless of
whether T
is
TrivialCopy
or
TriviallyRelocatable
. If T
is not
TrivialCopy
, using
the value in *dst
can violate memory safety. If T
is not
TriviallyRelocatable
, using both the
values in *src
and in *dst
can violate memory safety.
Note that even if the effectively copied size (count * size_of<T>()
) is 0,
the pointers must be non-null and properly aligned.