Please note that mem::uninitialized is always unsound. Your example should be using MaybeUninit<T>. While that example would still be unsound directly anyway, it at least gives you the ability to do the right thing (foo would need to take the MaybeUninit<i32>).