Re: [PATCH 2/2] rust: alloc: add `Vec::dec_len`

Danilo Krummrich
2025-03-17T11:22:36Z

On Sun, Mar 16, 2025 at 07:27:22PM -0400, Tamir Duberstein wrote:
>
> Does this suit?

I think for dec_ref() it is not the safety requrement that justifies the
invariant.

I think it should be something along the lines of:

// INVARIANT: We drop ownership for all elements within the range
// `[self.len - count, self.len]`, hence the updated value of `set.len`
// represents the exact number of elements stored within `self`.

>
> > // INVARIANT: By the safety requirements of this method `self.len - count` represents the
> > // exact number of elements stored within `self`.

Please do not use the email quote mechanism for code snippets, it's confusing
for readers to figure out by whom it has been written.