Re: [PATCH v4 02/16] rust: mem: add `transmute` with deferred size check

From: Miguel Ojeda

Date: Sat Sep 05 2026 - 15:19:43 EST


On Tue, Sep 1, 2026 at 6:50 PM Gary Guo <gary@xxxxxxxxxxx> wrote:
>
> +/// This can be used when types are known to have the same size, but only at runtime.
> +/// ```no_run

Newline between them.

> +/// // SAFETY: We've checked that `T` is u32!

`u32`

> +/// This is typically used in generic code where it's known that type will have the same size, but
> +/// the compiler cannot prove it generically.
> +/// ```no_run

Same.

> + // SAFETY: transmute is safe with `IntoBytes` and `FromBytes` bounds.

`transmute`

I think we could also link to the intrinsic and the `_neo` one,
perhaps with a permalink to avoid drift if they go away, but not a big
deal of course.

Cheers,
Miguel