Skip to content

Commit 3f1825a

Browse files
committed
Change std::mem::transmute_copy to use debug_assert!
Code that uses this function is likely performance-sensitive, so we do not want to emit an assert for dynamically-sized types in release mode.
1 parent c9575a6 commit 3f1825a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

library/core/src/mem/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1053,7 +1053,7 @@ pub const fn copy<T: Copy>(x: &T) -> T {
10531053
#[stable(feature = "rust1", since = "1.0.0")]
10541054
#[rustc_const_unstable(feature = "const_transmute_copy", issue = "83165")]
10551055
pub const unsafe fn transmute_copy<Src: ?Sized, Dst>(src: &Src) -> Dst {
1056-
assert!(
1056+
debug_assert!(
10571057
size_of_val(src) >= size_of::<Dst>(),
10581058
"cannot transmute_copy if Dst is larger than Src"
10591059
);

0 commit comments

Comments
 (0)