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

From: Alice Ryhl
Date: Fri May 03 2024 - 10:36:24 EST


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@xxxxxxxxx> 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.

Alice