Re: [PATCH v1 1/2] rust: Add support for calling a function exactly once

FUJITA Tomonori
2025-11-15T13:37:47Z

On Wed, 12 Nov 2025 10:04:15 +0100
Andreas Hindborg <a.hindborg@kernel.org> wrote:

>> Another change I'd like to propose is to use an enum, such as State,
>> instead of u32 for the init member, as I did in the OnceLite
>> implementation [1], something like:
>>
>> +#[derive(Clone, Copy, PartialEq, Eq)]
>> +#[repr(i32)]
>> +enum State {
>> + NotStarted = 0,
>> + InProgress = 1,
>> + Completed = 2,
>> +}
>> +
>> +unsafe impl AtomicType for State {
>> + type Repr = i32;
>> +}
>> +
>>
>> I think that this would make the code's intent clearer. What do you
>> think?
>>
>> If you think that change sounds reasonable, I can send a patch.
>
> The reason I did not do this was to avoid the unsafe impl. I don't have
> any strong opinion for either way though.

Understood, I don't have a strong preference either, so I'll leave it
as is. I'll send the other patches after 6.18.