Re: [PATCH 1/2] rust: sizes: add u64 variants of SZ_* constants

From: John Hubbard

Date: Wed Mar 11 2026 - 20:22:15 EST


On 3/11/26 1:01 AM, Alexandre Courbot wrote:
> 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?

I believe that's what I have locally, with DeviceSize, so I'll go
ahead and post it as v2, and let's see how it looks.

>
> 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.

thanks,
--
John Hubbard