For smallvec-like data structure I need to align the wrapper struct to alignment of its content. However, the standard 0-sized array trick for this is not suitable in this case:
struct Wrapper<T> {
align: [T; 0],
}
because it makes impossible to use this struct in a recursive type:
struct Wrapper<T> {
// align: [T; 0], // prevents recursive types
// phantom: PhantomData<T>, // doesn't align
}
enum Recursive {
A(Wrapper<Recursive>),
B,
}
Is there another method to copy alignment of an arbitrary type? This needs to be sound for large alignments too.