Fixed the {wrap/peel}_slice methods asserts: previously they were comparing the layouts of *const Inner and *const Self, which is are always the same when they're both Sized; now they check that Inner and Self have the same layout.
This could cause panics for existing users with incorrect TransparentWrapper implementations.
Added asserts to wrap and peel.
This could cause panics for existing users with incorrect TransparentWrapper implementations.
Added comments explaining why we compare size of *const Self in {wrap/peel}_{ref/mut/rc/arc/box}.
Moved some of the asserts and safety comments before the unsafe blocks (no semantic change, I just prefer it).
(I was going to also change the assert!s to debug_assert!s, but since the conditions are all const-foldable anyway, the only affect that would have would be hiding UB in release mode, with no benefit for correct implementations, so I left it using assert!)
{wrap/peel}_slice
methods asserts: previously they were comparing the layouts of*const Inner
and*const Self
, which is are always the same when they're bothSized
; now they check thatInner
andSelf
have the same layout.TransparentWrapper
implementations.wrap
andpeel
.TransparentWrapper
implementations.*const Self
in{wrap/peel}_{ref/mut/rc/arc/box}
.unsafe
blocks (no semantic change, I just prefer it).(I was going to also change the
assert!
s todebug_assert!
s, but since the conditions are all const-foldable anyway, the only affect that would have would be hiding UB in release mode, with no benefit for correct implementations, so I left it usingassert!
)