From mboxrd@z Thu Jan 1 00:00:00 1970 From: Claude Code Review Bot To: dri-devel-reviews@example.com Subject: Claude review: rust: sync: Add SetOnce::reset() Date: Thu, 04 Jun 2026 11:29:38 +1000 Message-ID: In-Reply-To: <20260603195210.693856-6-lyude@redhat.com> References: <20260603195210.693856-1-lyude@redhat.com> <20260603195210.693856-6-lyude@redhat.com> X-Mailer: Claude Code Patch Reviewer Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit MIME-Version: 1.0 Patch Review **Verdict: Looks good.** The `drop_val()` helper is a clean refactoring that avoids duplicating the drop logic between `reset()` and `Drop`. **The safety contract on `drop_val()` is precise:** ```rust /// # Safety /// /// If this function returns `true`, `self` must be freed or `init` must be reset to `0`. ``` This correctly documents the obligation on the caller. Both callsites uphold it: - `reset()` sets `init` to 0 if `drop_val()` returned true - `Drop` doesn't need to reset init since the whole struct is being freed **The invariant update is correct:** ```rust -/// - `init` may only increase in value. +/// - `init` may only increase in value, unless modified through a mutable reference. ``` This carves out the exact exception needed for `reset()`, which requires `&mut self`. **The doctest is a good addition** demonstrating the populate/reset/re-populate cycle. --- --- Generated by Claude Code Patch Reviewer