[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <DE06UXBAGY09.1D2TPYL4KNU56@kernel.org>
Date: Tue, 04 Nov 2025 21:21:58 +0100
From: "Danilo Krummrich" <dakr@...nel.org>
To: "Yury Norov" <yury.norov@...il.com>
Cc: "Alexandre Courbot" <acourbot@...dia.com>, "Alice Ryhl"
<aliceryhl@...gle.com>, "Miguel Ojeda" <ojeda@...nel.org>, "Joel Fernandes"
<joelagnelf@...dia.com>, "Jesung Yang" <y.j3ms.n@...il.com>, "Boqun Feng"
<boqun.feng@...il.com>, "Gary Guo" <gary@...yguo.net>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>, "Benno Lossin"
<lossin@...nel.org>, "Andreas Hindborg" <a.hindborg@...nel.org>, "Trevor
Gross" <tmgross@...ch.edu>, <linux-kernel@...r.kernel.org>,
<rust-for-linux@...r.kernel.org>
Subject: Re: [PATCH 1/2] rust: add BitInt integer wrapping type
On Tue Nov 4, 2025 at 8:30 PM CET, Yury Norov wrote:
> You switched name to BitInt, but still think about it as an object,
Note that in Rust even "real" primitives have a strong object character, they
have lots of methods, trait implementation and associated constants [1].
You can even implement your own custom traits for a primitive type in Rust.
[1] https://rust.docs.kernel.org/core/primitive.u32.html
> and that brought all the confusion in my mind. Maybe switch back to
> BoundedInt then to avoid this confusion? If you find it lengthy,
> probably LimInt or simply Lint will be better for you.
In another thread Alex proposed Bounded, because it follows the naming scheme of
other existing numeric types in Rust, e.g. NonZero [2].
[2] https://rust.docs.kernel.org/core/num/struct.NonZero.html
> Looking at how good rust macros work to implement bitfields, I thought
> that they will be able to mimic native types just as well.
I assume you mean primitive types. If so, I think there isn't too much we can't
do (e.g. literal syntax would be nice) with BitInt (or Bounded) that primitives
can do. Especially when we consider the strong object character of "real" Rust
primitives.
> With that in mind, I think that bounded integers are a bit out of
> scope of basic bit operations, and probably I'm not a right person
> to maintain them neither in Rust, nor in C.
I think it's fair to consider this kind of type as core Rust infrastructure.
Maybe a RUST [NUMERICS] entry would make sense? You could be a reviewer. :)
Powered by blists - more mailing lists