What changed, and why it matters
This commit adds a normal 'pop' method to a small internal vector-like data structure called ArrayVec. It is a routine API addition to make the type behave more like Rust's standard Vec. There is no indication of a security bug or fix.
No security action needed. Review as normal code-quality/API-completeness change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change adds ArrayVec::pop(), which decrements the length, reads the last initialized element via assume_init(), and replaces the slot with MaybeUninit::uninit(). The safety comment notes that elements in 0..len are initialized, which is the standard invariant for this kind of structure. The operation is the expected dual of the existing push() method and appears consistent with the type’s safety boundary.
Changed components
internals/src/array_vec.rsInspect captured patch +17 / −0
diff --git a/internals/src/array_vec.rs b/internals/src/array_vec.rs
index 40157a27..13c0f569 100644
--- a/internals/src/array_vec.rs
+++ b/internals/src/array_vec.rs
@@ -69,6 +69,23 @@ mod safety_boundary {
self.len += 1;
}
+ /// Removes the last element, returning it.
+ ///
+ /// # Returns
+ ///
+ /// None if the ArrayVec is empty.
+ pub fn pop(&mut self) -> Option<T> {
+ if self.len > 0 {
+ self.len -= 1;
+ // SAFETY: All elements in 0..len are initialized
+ let res = self.data[self.len];
+ self.data[self.len] = MaybeUninit::uninit();
+ Some(unsafe { res.assume_init() })
+ } else {
+ None
+ }
+ }
+
/// Copies and appends all elements from `slice` 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.