fixed can_transmute/SmallBox::is_inline

This commit is contained in:
Janis 2025-07-02 19:18:41 +02:00
parent 56faa52d0d
commit f4623d1205
2 changed files with 3 additions and 2 deletions

View file

@ -137,7 +137,8 @@ impl<T> SmallBox<T> {
// the value can be stored inline iff the size of T is equal or
// smaller than the size of the boxed type and the alignment of the
// boxed type is an integer multiple of the alignment of T
crate::can_transmute::<Box<MaybeUninit<T>>, T>()
(size_of::<Box<MaybeUninit<T>>>() >= size_of::<MaybeUninit<T>>())
& (align_of::<Box<MaybeUninit<T>>>() >= align_of::<MaybeUninit<T>>())
}
pub fn new(value: T) -> Self {

View file

@ -44,5 +44,5 @@ pub const fn can_transmute<A, B>() -> bool {
use core::mem::{align_of, size_of};
// We can transmute `A` to `B` iff `A` and `B` have the same size and the
// alignment of `A` is greater than or equal to the alignment of `B`.
size_of::<A>() <= size_of::<B>() && align_of::<A>() >= align_of::<B>()
(size_of::<A>() == size_of::<B>()) & (align_of::<A>() >= align_of::<B>())
}