[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJ-ks9m4iNFPz7fsaJqOqjdwCidMsc9BH4S3KLdVh7d6i70=xA@mail.gmail.com>
Date: Mon, 17 Mar 2025 07:34:58 -0400
From: Tamir Duberstein <tamird@...il.com>
To: Danilo Krummrich <dakr@...nel.org>
Cc: Andrew Ballance <andrewjballance@...il.com>, Alice Ryhl <aliceryhl@...gle.com>,
Miguel Ojeda <ojeda@...nel.org>, Alex Gaynor <alex.gaynor@...il.com>,
Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>,
Benno Lossin <benno.lossin@...ton.me>, Andreas Hindborg <a.hindborg@...nel.org>,
Trevor Gross <tmgross@...ch.edu>, rust-for-linux@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/2] rust: alloc: add `Vec::dec_len`
On Mon, Mar 17, 2025 at 7:22 AM Danilo Krummrich <dakr@...nel.org> wrote:
>
> 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.
Thanks, applied the suggestion.
Powered by blists - more mailing lists