Re: [PATCH v1] rust: workqueue: add ScopedQueue for lifetime bound items

From: Gary Guo

Date: Wed Jun 17 2026 - 10:11:20 EST


On Mon Jun 15, 2026 at 4:18 PM BST, Alice Ryhl wrote:
>> +/// An owned workqueue that can enqueue work items borrowing from `'scope`.
>> +///
>> +/// A `ScopedQueue` must not outlive data borrowed by its work items.
>> +pub struct ScopedQueue<'scope> {
>> + inner: OwnedQueue,
>> + _scope: PhantomData<&'scope mut &'scope ()>,
>
> I think this can be contra-variant:
>
> _scope: PhantomData<fn(&'scope ())>,

The function signature is contravariant, but the captured data is covariant, so
they combine to invariance.

Best,
Gary