Re: [PATCH] rust: add global lock support
From: Benno Lossin
Date: Mon Aug 26 2024 - 11:46:30 EST
On 26.08.24 17:31, Alice Ryhl wrote:
> On Mon, Aug 26, 2024 at 5:30 PM Benno Lossin <benno.lossin@xxxxxxxxx> wrote:
>> On 26.08.24 17:27, Alice Ryhl wrote:
>>> + /// Initialize a global lock.
>>> + ///
>>> + /// # Safety
>>> + ///
>>> + /// * This lock must have been created with [`unsafe_const_new`].
>>> + /// * This lock must be pinned.
>>
>> You could also ask for `self: Pin<&Self>` and remove this constraint, or
>> is that not possible in your use-case?
>
> The value is going to be in a static, and it's inconvenient to have to
> use Pin::new_unchecked when calling this initializer. Not sure much
> value is gained.
Can't you use `Pin::static_ref` [1]?
[1]: https://doc.rust-lang.org/std/pin/struct.Pin.html#method.static_ref
---
Cheers,
Benno