Skip to content

Commit 5d95a36

Browse files
committed
do not claim that transmute is like memcpy
1 parent 22d25f2 commit 5d95a36

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

library/core/src/intrinsics.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1212,8 +1212,9 @@ extern "rust-intrinsic" {
12121212
///
12131213
/// `transmute` is semantically equivalent to a bitwise move of one type
12141214
/// into another. It copies the bits from the source value into the
1215-
/// destination value, then forgets the original. It's equivalent to C's
1216-
/// `memcpy` under the hood, just like `transmute_copy`.
1215+
/// destination value, then forgets the original. Note that source and destination
1216+
/// are passed by-value, which means if `T` or `U` contains padding, that padding
1217+
/// might *not* be preserved by `transmute`.
12171218
///
12181219
/// Because `transmute` is a by-value operation, alignment of the *transmuted values
12191220
/// themselves* is not a concern. As with any other function, the compiler already ensures

0 commit comments

Comments
 (0)