avoid direct indexing in AlignedBox

This commit is contained in:
auronandace
2026-02-22 13:43:37 +00:00
parent aeb75d577f
commit a19be5da11
+6 -2
View File
@@ -116,8 +116,12 @@ impl<T: Clone + ValidForZero, const ALIGN: usize> Clone for AlignedBox<[T], ALIG
fn clone(&self) -> Self {
let mut new = Self::try_zeroed_slice(self.len())
.unwrap_or_else(|_| alloc::alloc::handle_alloc_error(self.layout()));
for i in 0..self.len() {
new[i].clone_from(&self[i]);
for (i, val) in self.iter().enumerate() {
if let Some(new_inner) = new.get_mut(i) {
new_inner.clone_from(val);
} else {
unreachable!();
}
}
new
}