diff options
| author | Ralf Jung <post@ralfj.de> | 2020-10-11 23:59:32 +0200 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2020-10-11 23:59:32 +0200 |
| commit | 95aac4487d1cb89913539619c201079d0fc2b463 (patch) | |
| tree | e8363714fe792442b07cd021acc83d402d1c2e31 | |
| parent | 06a079c43efb062e335e6e6c9dabd3c750619980 (diff) | |
| download | rust-95aac4487d1cb89913539619c201079d0fc2b463.tar.gz rust-95aac4487d1cb89913539619c201079d0fc2b463.zip | |
transmute_copy: explain that alignment is handled correctly
| -rw-r--r-- | library/core/src/mem/mod.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/library/core/src/mem/mod.rs b/library/core/src/mem/mod.rs index a2c7da6e695..e84014c68a6 100644 --- a/library/core/src/mem/mod.rs +++ b/library/core/src/mem/mod.rs @@ -884,10 +884,10 @@ pub fn drop<T>(_x: T) {} /// Interprets `src` as having type `&U`, and then reads `src` without moving /// the contained value. /// -/// This function will unsafely assume the pointer `src` is valid for -/// [`size_of::<U>`][size_of] bytes by transmuting `&T` to `&U` and then reading -/// the `&U`. It will also unsafely create a copy of the contained value instead of -/// moving out of `src`. +/// This function will unsafely assume the pointer `src` is valid for [`size_of::<U>`][size_of] +/// bytes by transmuting `&T` to `&U` and then reading the `&U` (except that this is done in a way +/// that is correct even when `&U` makes stricter alignment requirements than `&T`). It will also +/// unsafely create a copy of the contained value instead of moving out of `src`. /// /// It is not a compile-time error if `T` and `U` have different sizes, but it /// is highly encouraged to only invoke this function where `T` and `U` have the |
