Skip to content

Commit

Permalink
Constify mem::transmute_copy
Browse files Browse the repository at this point in the history
  • Loading branch information
usbalbin committed Mar 15, 2021
1 parent 45988ee commit db9a53b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion library/core/src/mem/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -933,7 +933,8 @@ pub fn drop<T>(_x: T) {}
/// ```
#[inline]
#[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 align_of::<U>() > align_of::<T>() {
// SAFETY: `src` is a reference which is guaranteed to be valid for reads.
Expand Down

0 comments on commit db9a53b

Please sign in to comment.