#[repr(C)]pub struct VecHeader {
pub capacity: u16,
pub element_count: u16,
pub element_size: u32,
pub padding: u32,
}Fields§
§capacity: u16Do not change the order of the fields!
Keep the capacity field at the start of the header for consistency across all container types. Placing it first simplifies copy operations: we can verify and preserve capacity before copying the remainder of the header in one contiguous operation.
element_count: u16Number of live (active) elements currently stored in the collection.
Always located at offset 2, enabling:
- Logical size: Represents the number of valid elements in use.
- Bounds checking: Index and assignment checks (
0 <= idx < element_count) can load this field in a single instruction. - Iteration: Iterators read this field to determine the end of the collection.
- ABI stability: External tools, debuggers, and serializers can consistently locate
capacityandelement_countacross all container types.
element_size: u32§padding: u32Trait Implementations§
Auto Trait Implementations§
impl Freeze for VecHeader
impl RefUnwindSafe for VecHeader
impl Send for VecHeader
impl Sync for VecHeader
impl Unpin for VecHeader
impl UnwindSafe for VecHeader
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more