rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Danilo Krummrich" <dakr@kernel.org>
To: "Yury Norov" <yury.norov@gmail.com>
Cc: "Alexandre Courbot" <acourbot@nvidia.com>,
	"Alice Ryhl" <aliceryhl@google.com>,
	"Miguel Ojeda" <ojeda@kernel.org>,
	"Joel Fernandes" <joelagnelf@nvidia.com>,
	"Jesung Yang" <y.j3ms.n@gmail.com>,
	"Boqun Feng" <boqun.feng@gmail.com>,
	"Gary Guo" <gary@garyguo.net>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Benno Lossin" <lossin@kernel.org>,
	"Andreas Hindborg" <a.hindborg@kernel.org>,
	"Trevor Gross" <tmgross@umich.edu>,
	linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org
Subject: Re: [PATCH 1/2] rust: add BitInt integer wrapping type
Date: Tue, 04 Nov 2025 21:21:58 +0100	[thread overview]
Message-ID: <DE06UXBAGY09.1D2TPYL4KNU56@kernel.org> (raw)
In-Reply-To: <aQpUSw49QptgxjFz@yury>

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

  reply	other threads:[~2025-11-04 20:22 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-31 13:39 [PATCH 0/2] rust: add BitInt type and use in Nova's bitfield macro Alexandre Courbot
2025-10-31 13:39 ` [PATCH 1/2] rust: add BitInt integer wrapping type Alexandre Courbot
2025-11-02  5:46   ` Alexandre Courbot
2025-11-03  2:17   ` Yury Norov
2025-11-03 10:47     ` Alice Ryhl
2025-11-03 14:31       ` Alexandre Courbot
2025-11-03 13:42     ` Alexandre Courbot
2025-11-03 13:57       ` Alexandre Courbot
2025-11-03 14:01         ` Danilo Krummrich
2025-11-03 19:36       ` Yury Norov
2025-11-04  3:13         ` Alexandre Courbot
2025-11-04 19:30           ` Yury Norov
2025-11-04 20:21             ` Danilo Krummrich [this message]
2025-11-05 14:03             ` Alexandre Courbot
2025-11-05 15:45               ` Yury Norov
2025-11-03 14:10     ` Miguel Ojeda
2025-11-03 14:26       ` Yury Norov
2025-11-03 14:44         ` Alexandre Courbot
2025-11-03 14:54         ` Miguel Ojeda
2025-11-03 19:43           ` Yury Norov
2025-11-03 20:00             ` Yury Norov
2025-10-31 13:39 ` [PATCH FOR REFERENCE 2/2] gpu: nova-core: use BitInt for bitfields Alexandre Courbot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DE06UXBAGY09.1D2TPYL4KNU56@kernel.org \
    --to=dakr@kernel.org \
    --cc=a.hindborg@kernel.org \
    --cc=acourbot@nvidia.com \
    --cc=aliceryhl@google.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=gary@garyguo.net \
    --cc=joelagnelf@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lossin@kernel.org \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=tmgross@umich.edu \
    --cc=y.j3ms.n@gmail.com \
    --cc=yury.norov@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).