fixed can_transmute/SmallBox::is_inline
This commit is contained in:
parent
56faa52d0d
commit
f4623d1205
|
@ -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 {
|
||||
|
|
|
@ -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>())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue