[PATCH] rust: num: bounded: rename `try_into_bitint` to `try_into_bounded`

Alexandre Courbot posted 1 patch 1 week ago
rust/kernel/num/bounded.rs | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
[PATCH] rust: num: bounded: rename `try_into_bitint` to `try_into_bounded`
Posted by Alexandre Courbot 1 week ago
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>
Re: [PATCH] rust: num: bounded: rename `try_into_bitint` to `try_into_bounded`
Posted by Miguel Ojeda 1 week ago
On Mon, Nov 24, 2025 at 2:50 PM Alexandre Courbot <acourbot@nvidia.com> wrote:
>
> 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>

Applied to `rust-next` -- thanks!

Hmm... This is the sort of thing where I am not sure if it should
count as a fix, since while it is unexpected, there is nothing
actually broken. I kept the tag since you provided it anyway.

Cheers,
Miguel