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 12:29:53 +1000 Message-ID: In-Reply-To: <20260602172807.1051806-4-lyude@redhat.com> References: <20260602172807.1051806-1-lyude@redhat.com> <20260602172807.1051806-4-lyude@redhat.com> X-Mailer: Claude Code Patch Reviewer Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Patch Review Adds `reset()` which takes `&mut self` (proving exclusive access), drops th= e value, and resets `init` to 0. **Invariant update**: The change from "init may only increase in value" to = "init may only increase in value, unless modified through a mutable referen= ce" is correct =E2=80=94 `&mut self` guarantees no concurrent observers. **`drop_val` safety contract**: The `unsafe fn drop_val` has a critical saf= ety requirement: ```rust /// If this function returns `true`, `self` must be freed or `init` must be= reset to `0`. ``` Between `drop_val()` returning `true` and the caller resetting `init`, ther= e's a window where `init =3D=3D 2` but the value is dropped. This is safe b= ecause `&mut self` ensures exclusive access, but the contract is correctly = documented. Both callers (`reset` and `Drop`) satisfy it. **Doctest**: The example is good and demonstrates the full reset/repopulate= cycle: ```rust assert_eq!(value.populate(67), true); assert_eq!(value.reset(), true); assert!(value.as_ref().is_none()); assert_eq!(value.reset(), false); assert_eq!(value.populate(69), true); ``` No issues. --- Generated by Claude Code Patch Reviewer