Re: [PATCH v3 1/3] rust: Introduce irq module
From: Benno Lossin
Date: Thu Aug 15 2024 - 17:48:44 EST
On 15.08.24 22:31, Lyude Paul wrote:
> On Wed, 2024-08-14 at 13:17 -0700, Boqun Feng wrote:
>> On Wed, Aug 14, 2024 at 03:38:47PM -0400, Lyude Paul wrote:
>>> On Wed, 2024-08-14 at 10:35 -0700, Boqun Feng wrote:
>>>> note that `cb` is a `-> T` function, other than `-> (IrqDisabled<'a>,
>>>> T)`, so semantically, it doesn't require IRQ still disabled after
>>>> return.
>>>
>>> This was the reason I originally had us pass IrqDisabled as a reference and
>>> not a value - specifically since it seemed to make more sense to treat
>>> IrqDisabled as an object which exists throughout the lifetime of the closure
>>> regardless of whether we drop our reference to it or not - since it's a no-op.
>>>
>>
>> I haven't found a problem with `&IrqDisabled` as the closure parameter,
>> but I may miss something.
>
> I had been asked by Benno to change it to by-value but it wasn't totally clear
> to me either what the reasoning was.
I wanted to avoid reborrows. The parameter of the closure has always
been `IrqDisabled`, but functions that required IRQs to be disabled took
`&IrqDisabled<'a>`.
---
Cheers,
Benno