Re: [PATCH] rust: add global lock support
From: Alice Ryhl
Date: Tue Aug 27 2024 - 04:44:54 EST
On Mon, Aug 26, 2024 at 5:46 PM Benno Lossin <benno.lossin@xxxxxxxxx> wrote:
>
> 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
That's an excellent point, thanks. Sent a new version with that.
Alice