Re: [PATCH v6 4/4] rust: add abstraction for `struct page`

From: Gary Guo
Date: Thu Apr 25 2024 - 12:20:32 EST


On Thu, 18 Apr 2024 15:56:11 -0700
Boqun Feng <boqun.feng@xxxxxxxxx> wrote:

> Hmm.. here is the thing, having `&UnsafeCell<[u8]>` means having a `*mut
> [u8]>`, and it should always be safe to get a "length" of `*mut [u8]`,
> right? I haven't found any method doing that, but the length should be
> just a part of fat pointer, so I think getting that is a defined
> behavior. But maybe I'm missing something.

You can just use `unsafe_cell.get().len()`. `len` method exists on
raw slice pointers, gated by the `slice_ptr_len` feature, which will
be stable in 1.79.0.

Best,
Gary