Re: [PATCH v4 03/16] rust: mem: add `AsRepr` and `AsReprMut`
From: Gary Guo
Date: Sat Sep 05 2026 - 19:33:14 EST
On Sat Sep 5, 2026 at 8:22 PM BST, Miguel Ojeda wrote:
> On Tue, Sep 1, 2026 at 6:50 PM Gary Guo <gary@xxxxxxxxxxx> wrote:
>>
>> + /// Convert from `Self` to [`Self::Repr`].
>
> I think [`Self`] etc. work too.
I'm not sure why we'd want a self link.
Best,
Gary
>
>> +/// - [`Self`] must be [transmutable] from [`Self::Repr`].
>
> We say "can" in the `AsRepr` one -- we should be consistent.
>
>> +// SAFETY: `bool` has the same size and alignment as `u8`, and Rust guarantees that `bool` has
>> +// only two valid bit patterns: 0 (false) and 1 (true). Thus `bool` can be transmuted to `u8`.
>
> `false`, `true`
>
>> + // SAFETY: $unsigned has the same size and alignment with itself, and is transmutable to
>
> `$unsigned` (a few below).
>
> Cheers,
> Miguel