Re: [PATCH v4 03/16] rust: mem: add `AsRepr` and `AsReprMut`
From: Miguel Ojeda
Date: Sat Sep 05 2026 - 15:22:53 EST
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.
> +/// - [`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