But after read the docs carefully, we found that it said that it is advisable to avoid them because it could cause immediate undefined behavior in someday (when the rules around uninitialized integers are finalized).
Now, there is no suitable API for that, so just remove the unsafe code.
First, the code works fine with current stable rust toolchain. But, rust toolchain doesn't guarantee that; so it could be broken in the future.
The latest docs said:
And, there is no safe way to create an uninitialized array.
At first,
::std::mem::uninitialized()
was the suggested method.One day, the compiler told us to replace that by
MaybeUninit::uninit().assume_init()
.But after read the docs carefully, we found that it said that it is advisable to avoid them because it could cause immediate undefined behavior in someday (when the rules around uninitialized integers are finalized).
Now, there is no suitable API for that, so just remove the unsafe code.
I find one API which looks well but still unstable.