Re: [PATCH v17 5/6] rust: sync: Add SetOnce::reset()
From: Alice Ryhl
Date: Thu Jun 04 2026 - 07:58:44 EST
On Wed, Jun 03, 2026 at 03:42:34PM -0400, Lyude Paul wrote:
> This function simply drops the contents of the SetOnce, given a mutable
> reference - since that proves we have exclusive access to the SetOnce.
> Additionally, update the invariants for SetOnce to make it clear as to why
> this is safe.
>
> Signed-off-by: Lyude Paul <lyude@xxxxxxxxxx>
This isn't needed, you can just do:
unsafe { (*this).sgt_res = SetOnce::new() };