[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aQxuXd0-EycU7p65@google.com>
Date: Thu, 6 Nov 2025 09:46:05 +0000
From: Alice Ryhl <aliceryhl@...gle.com>
To: Alexandre Courbot <acourbot@...dia.com>
Cc: Danilo Krummrich <dakr@...nel.org>, Miguel Ojeda <ojeda@...nel.org>,
Joel Fernandes <joelagnelf@...dia.com>, Yury Norov <yury.norov@...il.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 v3 1/4] rust: add num module and Integer trait
On Thu, Nov 06, 2025 at 04:07:13PM +0900, Alexandre Courbot wrote:
> Introduce the `num` module, which will provide numerical extensions and
> utilities for the kernel.
>
> For now, introduce the `Integer` trait, which is implemented for all
> primitive integer types to provides their core properties to generic
> code.
>
> Signed-off-by: Alexandre Courbot <acourbot@...dia.com>
> ---
> rust/kernel/lib.rs | 1 +
> rust/kernel/num.rs | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 77 insertions(+)
>
> diff --git a/rust/kernel/lib.rs b/rust/kernel/lib.rs
> index 3dd7bebe7888..235d0d8b1eff 100644
> --- a/rust/kernel/lib.rs
> +++ b/rust/kernel/lib.rs
> @@ -109,6 +109,7 @@
> pub mod mm;
> #[cfg(CONFIG_NET)]
> pub mod net;
> +pub mod num;
> pub mod of;
> #[cfg(CONFIG_PM_OPP)]
> pub mod opp;
> diff --git a/rust/kernel/num.rs b/rust/kernel/num.rs
> new file mode 100644
> index 000000000000..3f85e50b8632
> --- /dev/null
> +++ b/rust/kernel/num.rs
> @@ -0,0 +1,76 @@
> +// SPDX-License-Identifier: GPL-2.0
> +
> +//! Additional numerical features for the kernel.
> +
> +use core::ops;
> +
> +/// Designates unsigned primitive types.
> +pub struct Unsigned(());
> +
> +/// Designates signed primitive types.
> +pub struct Signed(());
Since these types are not intended to be constructed, I would suggest
using enums so that they can't be constructed:
pub enum Unsigned {}
pub enum Signed {}
Alice
Powered by blists - more mailing lists