Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions framework/base/src/types/managed/wrapped/managed_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,8 @@ use crate::{
};
use alloc::{format, vec::Vec};
use core::{
borrow::Borrow,
cmp::Ordering,
fmt::Debug,
iter::FromIterator,
marker::PhantomData,
mem::{transmute_copy, ManuallyDrop, MaybeUninit},
borrow::Borrow, cmp::Ordering, fmt::Debug, iter::FromIterator, marker::PhantomData,
mem::MaybeUninit,
};

pub(crate) const INDEX_OUT_OF_RANGE_MSG: &[u8] = b"ManagedVec index out of range";
Expand Down Expand Up @@ -184,8 +180,7 @@ where
return None;
}

let mut result_uninit =
unsafe { MaybeUninit::<[MaybeUninit<T::Ref<'_>>; N]>::uninit().assume_init() };
let mut result_uninit: [MaybeUninit<T::Ref<'_>>; N] = [const { MaybeUninit::uninit() }; N];

for (index, value) in self.iter().enumerate() {
// length already checked
Expand All @@ -194,7 +189,8 @@ where
}
}

let result = unsafe { transmute_copy(&ManuallyDrop::new(result_uninit)) };
// TODO: replace with MaybeUninit::array_assume_init when it gets stabilized
let result = unsafe { core::mem::transmute_copy(&result_uninit) };
Some(result)
}

Expand Down
Loading