Re: [PATCH 4/7] rust: sync: introduce `ArcBorrow`

From: Gary Guo
Date: Mon Jan 16 2023 - 17:08:13 EST


On Wed, 4 Jan 2023 17:06:50 +0100
Emilio Cobos Álvarez <emilio@xxxxxxxxx> wrote:

> Sorry for the drive-by comment, but maybe it saves some work.
>
> On 1/4/23 16:29, Wedson Almeida Filho wrote:
> > On Sat, 31 Dec 2022 at 19:43, Gary Guo <gary@xxxxxxxxxxx> wrote:
> >>
> >> On Wed, 28 Dec 2022 06:03:43 +0000
> >> Wedson Almeida Filho <wedsonaf@xxxxxxxxx> wrote:
> >>> +pub struct ArcBorrow<'a, T: ?Sized + 'a> {
> >>> + inner: NonNull<ArcInner<T>>,
> >>> + _p: PhantomData<&'a ()>,
> >>> +}
> >>> +
> >>> +impl<T: ?Sized> Clone for ArcBorrow<'_, T> {
> >>> + fn clone(&self) -> Self {
> >>> + *self
> >>> + }
> >>> +}
> >>> +
> >>> +impl<T: ?Sized> Copy for ArcBorrow<'_, T> {}
> >>
> >> Couldn't this just be derived `Clone` and `Copy`?
> >
> > Indeed. I'll send a v2 with this.
>
> I'm not sure this is true. Deriving will add the T: Copy and T: Clone
> bound, which I think is not what you want here.
>
> i.e., I assume you want an ArcBorrow to be Copy even if the underlying T
> is not.

Thanks for pointing out, I neglected that.

In this case:

Reviewed-by: Gary Guo <gary@xxxxxxxxxxx>