File tree 1 file changed +7
-1
lines changed
1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -732,7 +732,7 @@ pub const fn swap<T>(x: &mut T, y: &mut T) {
732
732
// tends to copy the whole thing to stack rather than doing it one part
733
733
// at a time, so instead treat them as one-element slices and piggy-back
734
734
// the slice optimizations that will split up the swaps.
735
- if size_of :: < T > ( ) / align_of :: < T > ( ) > 4 {
735
+ if T :: IS_BIG_SWAP {
736
736
// SAFETY: exclusive references always point to one non-overlapping
737
737
// element and are non-null and properly aligned.
738
738
return unsafe { ptr:: swap_nonoverlapping ( x, y, 1 ) } ;
@@ -1273,3 +1273,9 @@ pub trait SizedTypeProperties: Sized {
1273
1273
#[ doc( hidden) ]
1274
1274
#[ unstable( feature = "sized_type_properties" , issue = "none" ) ]
1275
1275
impl < T > SizedTypeProperties for T { }
1276
+
1277
+ trait InternalSizedTypeProperties : Sized {
1278
+ const IS_BIG_SWAP : bool = size_of :: < Self > ( ) / align_of :: < Self > ( ) > 4 ;
1279
+ }
1280
+
1281
+ impl < T > InternalSizedTypeProperties for T { }
You can’t perform that action at this time.
0 commit comments