Re: [PATCH v2 3/6] rust: arc: split unsafe block, add missing comment
From: Alice Ryhl
Date: Fri Nov 08 2024 - 07:47:40 EST
On Fri, Nov 8, 2024 at 1:41 PM Tamir Duberstein <tamird@xxxxxxxxx> wrote:
>
> On Fri, Nov 8, 2024 at 7:37 AM Alice Ryhl <aliceryhl@xxxxxxxxxx> wrote:
> > You could write `unsafe { (*self.ptr.as_ptr()).refcount.get() }` to
> > avoid the as_ref call.
>
> Doesn't `(*self.ptr.as_ptr())` have the same problem?
It's not quite the same. Both `*ptr` and `(*ptr).field` are place
expressions which do not inherently involve the creation of a
reference in the way that `NonNull::as_ref` does.
Alice