pub const fn can_transmute() -> 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::() == size_of::()) & (align_of::() >= align_of::()) } pub const fn is_same_size() -> bool { use core::mem::size_of; size_of::() == size_of::() } /// Checks if `A` is aligned at least as well as `B`. e.g. `assert_aligned()` returns `true`, but `assert_aligned()` returns /// `false`. This is useful for ensuring that a type `A` can be safely cast to a /// type `B` without violating alignment requirements. pub const fn is_aligned() -> bool { use core::mem::align_of; align_of::() >= align_of::() }