I think we can solve the SmallVec
problem by introducing a MaybeUninitialized
library type.
union MaybeUninitialized<T> {
value: T,
// to solve https://github.com/rust-lang/rust/issues/36394,
// can be implemented today with a #[lang="maybe_uninitialized"]
buf: [u8; mem::size_of::<T>]
}
impl<T> MaybeInitialized<T> {
fn new_uninitialized() -> Self {
unsafe { mem::uninitialized() }
}
fn new(value: T) -> Self {
MaybeInitialized { value: value }
}
fn get_mut(&mut self) -> *mut T {
&mut self.value
}
fn get(&self) -> *const T {
&self.value
}
// more APIs might be implemented
}