Re: [PATCH v11 1/4] rust: types: Add Ownable/Owned types
From: Andreas Hindborg
Date: Wed Aug 20 2025 - 06:49:01 EST
"Benno Lossin" <lossin@xxxxxxxxxx> writes:
> On Tue Aug 19, 2025 at 11:00 AM CEST, Andreas Hindborg wrote:
>> "Oliver Mangold" <oliver.mangold@xxxxx> writes:
>>> You mean of `Ownable`, when `OwnableMut` is removed? Yes. A good question
>>> in that context is, what it actually means to have an `&mut Opaque<T>`
>>> where `T` is `Unpin`. If that implies being allowed to obtain an `&mut T`,
>>> it would we easy, I guess.
>>
>> You should not be able to get a `&mut T` from a `&mut Opaque<T>`.
>> `Opaque` opts out of invariants that normally hold for rust references.
>
> Yes, that function mustn't exist.
>
>>> But what I am wondering is, if we actually want to start using `Pin`
>>> at all. Isn't `Opaque` currently used about everywhere pinning is needed?
>>
>> `Opaque` is `!Unpin`, but pinning guarantees does not come into effect
>> until we produce a `Pin<Opaque<T>>`.
>
> `Pin<Opaque<T>>` isn't really a thing. You still need a pointer
> indirection, so `Pin<P>` where `P: DerefMut<Target = Opaque<T>>` so for
> example `Pin<Box<Opaque<T>>>`.
Right, that is what I meant, but not what I typed. Thanks for pointing
that out :)
Best regards,
Andreas Hindborg