Skip to content

Commit 95aac44

Browse files
committed
transmute_copy: explain that alignment is handled correctly
1 parent 06a079c commit 95aac44

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Diff for: library/core/src/mem/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -884,10 +884,10 @@ pub fn drop<T>(_x: T) {}
884884
/// Interprets `src` as having type `&U`, and then reads `src` without moving
885885
/// the contained value.
886886
///
887-
/// This function will unsafely assume the pointer `src` is valid for
888-
/// [`size_of::<U>`][size_of] bytes by transmuting `&T` to `&U` and then reading
889-
/// the `&U`. It will also unsafely create a copy of the contained value instead of
890-
/// moving out of `src`.
887+
/// This function will unsafely assume the pointer `src` is valid for [`size_of::<U>`][size_of]
888+
/// bytes by transmuting `&T` to `&U` and then reading the `&U` (except that this is done in a way
889+
/// that is correct even when `&U` makes stricter alignment requirements than `&T`). It will also
890+
/// unsafely create a copy of the contained value instead of moving out of `src`.
891891
///
892892
/// It is not a compile-time error if `T` and `U` have different sizes, but it
893893
/// is highly encouraged to only invoke this function where `T` and `U` have the

0 commit comments

Comments
 (0)