util: add safety comment to assume_init (#4075)

This commit is contained in:
Alice Ryhl 2021-08-26 23:06:58 +02:00 committed by GitHub
parent 1e2e38b7cd
commit 8a097d27b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -12,7 +12,13 @@ pub(crate) struct WakeList {
impl WakeList {
pub(crate) fn new() -> Self {
Self {
inner: unsafe { MaybeUninit::uninit().assume_init() },
inner: unsafe {
// safety: Create an uninitialized array of `MaybeUninit`. The
// `assume_init` is safe because the type we are claiming to
// have initialized here is a bunch of `MaybeUninit`s, which do
// not require initialization.
MaybeUninit::uninit().assume_init()
},
curr: 0,
}
}