Re: [PATCH 1/2] rust: sizes: add u64 variants of SZ_* constants
From: Alexandre Courbot
Date: Wed Mar 11 2026 - 04:11:44 EST
On Tue Mar 10, 2026 at 10:51 PM JST, Miguel Ojeda wrote:
> On Tue, Mar 10, 2026 at 3:31 AM John Hubbard <jhubbard@xxxxxxxxxx> wrote:
>>
>> +// CAST: every SZ_* value below fits in u64, so `as u64` is always lossless.
>
> Nit:
>
> // CAST: Every `SZ_*` value below fits in `u64`, so `as u64` is
> always lossless.
>
> One alternative could be something like `sizes::u64::SZ_1M`, but if
> you expect to mix `usize` and `u64` often then it may not be great.
How about an extension trait for integer types with all the `SZ_*`
defined as constants?
That would allow easy implementation for more integer types, like
`Bounded`. Because "64 bit" address spaces are often actually less than
that, and we might want to work with `Bounded` for them.