Re: [PATCH v4 1/3] rust: revocable: update write invariant and fix safety comments

Benno Lossin
2025-06-17T07:18:44Z

On Tue Jun 17, 2025 at 4:49 AM CEST, Marcelo Moreira wrote:
> Em seg., 16 de jun. de 2025 às 04:15, Benno Lossin <lossin@kernel.org> escreveu:
>> How about:
>>
>> // - `self.data` is valid for writes because of `Self`'s type invariants:
>> // `&mut Self` guarantees exclusive access, thus no other thread can concurrently access `data`.
>> // - this function is a drop function, thus this code is at most executed once.
>
> Ok! =)
>
> I thought about using "so" instead of the first "thus" so I wouldn't
> have to repeat the use of "thus" so many times.

I personally don't care about repeating those "filler" words in safety
documentation. The clearer it is the better :)

> Final version:
> // - `self.data` is valid for writes because of `Self`'s type invariants:
> // `&mut Self` guarantees exclusive access, so no other thread can
> concurrently access `data`.
> // - this function is a drop function, thus this code is at most executed once.

That is fine too.

---
Cheers,
Benno