What changed, and why it matters
This commit adds a small helper method to an internal array-backed vector type. It simply exposes the unused portion of the underlying array as a mutable slice of uninitialized memory. There is no security issue visible in the change itself.
No security action required. Review as normal code-quality change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch adds ArrayVec::spare_capacity_mut, mirroring Vec::spare_capacity_mut. It returns &mut self.data[self.len..], i.e., the tail of the fixed-size array beyond the current logical length. The method is safe because it only returns MaybeUninit<T> references; callers cannot observe or produce initialized values without additional unsafe code. No existing invariants are weakened and no unsafe code is introduced.
Changed components
internals/src/array_vec.rsInspect captured patch +5 / −0
diff --git a/internals/src/array_vec.rs b/internals/src/array_vec.rs
index 24a39e19..c7e2be3b 100644
--- a/internals/src/array_vec.rs
+++ b/internals/src/array_vec.rs
@@ -61,6 +61,11 @@ mod safety_boundary {
unsafe { core::slice::from_raw_parts_mut(ptr, self.len) }
}
+ /// Returns remaining spare capacity of the vector as a slice of `MaybeUninit<T>`.
+ pub fn spare_capacity_mut(&mut self) -> &mut [MaybeUninit<T>] {
+ &mut self.data[self.len..]
+ }
+
/// Adds an element into `self`.
///
/// # Panics
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.