From: Alexandre Courbot <acourbot@nvidia.com>
To: "Miguel Ojeda" <ojeda@kernel.org>,
"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>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>,
"Danilo Krummrich" <dakr@kernel.org>
Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org,
Alexandre Courbot <acourbot@nvidia.com>
Subject: [PATCH] rust: num: bounded: rename `try_into_bitint` to `try_into_bounded`
Date: Mon, 24 Nov 2025 22:50:02 +0900 [thread overview]
Message-ID: <20251124-bounded_fix-v1-1-d8e34e1c727f@nvidia.com> (raw)
This is a remnant from when `Bounded` was called `BitInt` which I didn't
rename. Fix this.
Fixes: 01e345e82ec3 ("rust: num: add Bounded integer wrapping type")
Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
---
Not sure how this happened, but let's fix this early. Feel free to
rebase/squash if that's still an option.
---
rust/kernel/num/bounded.rs | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/rust/kernel/num/bounded.rs b/rust/kernel/num/bounded.rs
index 92c41b2eb760..f870080af8ac 100644
--- a/rust/kernel/num/bounded.rs
+++ b/rust/kernel/num/bounded.rs
@@ -218,11 +218,11 @@ fn fits_within<T: Integer>(value: T, num_bits: u32) -> bool {
/// use kernel::num::{Bounded, TryIntoBounded};
///
/// // Succeeds because `128` fits into 8 bits.
-/// let v: Option<Bounded<u16, 8>> = 128u32.try_into_bitint();
+/// let v: Option<Bounded<u16, 8>> = 128u32.try_into_bounded();
/// assert_eq!(v.as_deref().copied(), Some(128));
///
/// // Fails because `128` doesn't fits into 6 bits.
-/// let v: Option<Bounded<u16, 6>> = 128u32.try_into_bitint();
+/// let v: Option<Bounded<u16, 6>> = 128u32.try_into_bounded();
/// assert_eq!(v, None);
/// ```
#[repr(transparent)]
@@ -498,18 +498,18 @@ fn deref(&self) -> &Self::Target {
/// use kernel::num::{Bounded, TryIntoBounded};
///
/// // Succeeds because `128` fits into 8 bits.
-/// let v: Option<Bounded<u16, 8>> = 128u32.try_into_bitint();
+/// let v: Option<Bounded<u16, 8>> = 128u32.try_into_bounded();
/// assert_eq!(v.as_deref().copied(), Some(128));
///
/// // Fails because `128` doesn't fits into 6 bits.
-/// let v: Option<Bounded<u16, 6>> = 128u32.try_into_bitint();
+/// let v: Option<Bounded<u16, 6>> = 128u32.try_into_bounded();
/// assert_eq!(v, None);
/// ```
pub trait TryIntoBounded<T: Integer, const N: u32> {
/// Attempts to convert `self` into a [`Bounded`] using `N` bits.
///
/// Returns [`None`] if `self` does not fit into the target type.
- fn try_into_bitint(self) -> Option<Bounded<T, N>>;
+ fn try_into_bounded(self) -> Option<Bounded<T, N>>;
}
/// Any integer value can be attempted to be converted into a [`Bounded`] of any size.
@@ -518,7 +518,7 @@ impl<T, U, const N: u32> TryIntoBounded<T, N> for U
T: Integer,
U: TryInto<T>,
{
- fn try_into_bitint(self) -> Option<Bounded<T, N>> {
+ fn try_into_bounded(self) -> Option<Bounded<T, N>> {
self.try_into().ok().and_then(Bounded::try_new)
}
}
---
base-commit: bc197e24a3acd13dd0b7b07c1448c5c225946546
change-id: 20251124-bounded_fix-db070b497b97
Best regards,
--
Alexandre Courbot <acourbot@nvidia.com>
next reply other threads:[~2025-11-24 13:50 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-24 13:50 Alexandre Courbot [this message]
2025-11-24 16:14 ` [PATCH] rust: num: bounded: rename `try_into_bitint` to `try_into_bounded` Miguel Ojeda
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=20251124-bounded_fix-v1-1-d8e34e1c727f@nvidia.com \
--to=acourbot@nvidia.com \
--cc=a.hindborg@kernel.org \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=dakr@kernel.org \
--cc=gary@garyguo.net \
--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 \
/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).