mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-04 19:29:07 +00:00
Constify mem::transmute_copy
This commit is contained in:
parent
45988ee438
commit
db9a53b5d7
@ -933,7 +933,8 @@ pub fn drop<T>(_x: T) {}
|
|||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
pub unsafe fn transmute_copy<T, U>(src: &T) -> U {
|
#[rustc_const_unstable(feature = "const_transmute_copy", issue = "83165")]
|
||||||
|
pub const unsafe fn transmute_copy<T, U>(src: &T) -> U {
|
||||||
// If U has a higher alignment requirement, src may not be suitably aligned.
|
// If U has a higher alignment requirement, src may not be suitably aligned.
|
||||||
if align_of::<U>() > align_of::<T>() {
|
if align_of::<U>() > align_of::<T>() {
|
||||||
// SAFETY: `src` is a reference which is guaranteed to be valid for reads.
|
// SAFETY: `src` is a reference which is guaranteed to be valid for reads.
|
||||||
|
Loading…
Reference in New Issue
Block a user