ptr::copy_nonoverlapping
/ptr::copy
docs mention order difference between memcpy/memmove but fail to note count unit difference
#79430
Labels
A-docs
Area: Documentation for any part of the project, including the compiler, standard library, and tools
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
T-libs-api
Relevant to the library API team, which will review and decide on the PR/issue.
The docs for
ptr::copy_nonoverlapping
andptr::copy
say things like:and
This is true, but I just encountered code where these were more-or-less used as:
and the author (and myself) were confused about the issue here due to this basically looking right. The problem here is that unlike
memcpy
/memmove
thesize_of::<T>() * n
should just ben
, since it's the number ofT
s to copy.I've filed a clippy lint for this: rust-lang/rust-clippy#6381, but the docs should be updated to clarify this difference.
The text was updated successfully, but these errors were encountered: