Re: [PATCH 1/9] rust: list: add ListArc

From: Benno Lossin
Date: Sat May 04 2024 - 11:51:10 EST


On 03.05.24 16:36, Alice Ryhl wrote:
> On Thu, Apr 4, 2024 at 4:00 PM Alice Ryhl <aliceryhl@xxxxxxxxxx> wrote:
>>
>> On Wed, Apr 3, 2024 at 5:51 PM Benno Lossin <benno.lossin@protonme> wrote:
>>>
>>> On 02.04.24 14:16, Alice Ryhl wrote:
>>>> +impl<T: ListArcSafe<ID>, const ID: u64> ListArc<T, ID> {
>>>> + /// Constructs a new reference counted instance of `T`.
>>>> + pub fn try_new(contents: T) -> Result<Self, AllocError> {
>>>> + Ok(Self::from_unique(UniqueArc::try_new(contents)?))
>>>> + }
>>>> +
>>>> + /// Use the given initializer to in-place initialize a `T`.
>>>> + ///
>>>> + /// If `T: !Unpin` it will not be able to move afterwards.
>>>> + pub fn pin_init<E>(init: impl PinInit<T, E>) -> error::Result<Self>
>>>> + where
>>>> + Error: From<E>,
>>>> + {
>>>> + Ok(Self::from_pin_unique(UniqueArc::pin_init(init)?))
>>>> + }
>>>
>>> pin-init has a general trait for this: InPlaceInit. I don't know if the
>>> other functions that it provides would help you.
>>
>> I will use that.
>
> Turns out it's not possible to use the trait in this case, for the
> same reasons as why Arc isn't using them either.

Ugh that is annoying, I think we can change `InPlaceInit` to have a
`PinnedSelf` associated type. I will create a good-first-issue.

--
Cheers,
Benno