diff options
author | Tamir Duberstein <tamird@gmail.com> | 2025-04-16 13:15:40 -0400 |
---|---|---|
committer | Danilo Krummrich <dakr@kernel.org> | 2025-04-23 12:05:15 +0200 |
commit | 47a17a63f9e23f7e8f39d0965bcda8fee6c322f8 (patch) | |
tree | f5c92037c954e0e3bae215c98ee8826af6ec6670 /rust/kernel/security.rs | |
parent | 85f8e98dbb0135d2bc1999c6015cd374fe2c69fa (diff) |
rust: alloc: add Vec::len() <= Vec::capacity invariant
Document the invariant that the vector's length is always less than or
equal to its capacity. This is already implied by these other
invariants:
- `self.len` always represents the exact number of elements stored in
the vector.
- `self.layout` represents the absolute number of elements that can be
stored within the vector without re-allocation.
but it doesn't hurt to spell it out. Note that the language references
`self.capacity` rather than `self.layout.len` as the latter is zero for
a vector of ZSTs.
Update a safety comment touched by this patch to correctly reference
`realloc` rather than `alloc` and replace "leaves" with "leave" to
improve grammar.
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Signed-off-by: Tamir Duberstein <tamird@gmail.com>
Link: https://lore.kernel.org/r/20250416-vec-set-len-v4-1-112b222604cd@gmail.com
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
Diffstat (limited to 'rust/kernel/security.rs')
0 files changed, 0 insertions, 0 deletions