Files
linux/rust/kernel
Tamir Duberstein 47a17a63f9 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>
2025-04-23 12:05:15 +02:00
..
2025-03-10 15:12:17 +01:00
2025-03-16 21:59:19 +01:00
2025-02-22 15:44:19 +01:00
2025-03-16 21:59:19 +01:00
2024-12-20 17:21:04 +01:00
2024-10-08 15:44:36 +02:00
2025-03-16 21:59:19 +01:00
2024-12-20 17:19:26 +01:00
2024-11-04 16:21:44 -05:00
2025-03-16 21:59:19 +01:00