[PATCH v5 05/23] rust: num: add the `fls` operation

Miguel Ojeda miguel.ojeda.sandonis at gmail.com
Sun Jun 15 09:37:21 UTC 2025


On Thu, Jun 12, 2025 at 4:02 PM Alexandre Courbot <acourbot at nvidia.com> wrote:
>
> +            /// ```
> +            /// use kernel::num::fls_u32;
> +            ///
> +            /// assert_eq!(fls_u32(0x0), 0);
> +            /// assert_eq!(fls_u32(0x1), 1);
> +            /// assert_eq!(fls_u32(0x10), 5);
> +            /// assert_eq!(fls_u32(0xffff), 16);
> +            /// assert_eq!(fls_u32(0x8000_0000), 32);
> +            /// ```

For a future patch series: this could provide examples per type
(passing them in the `impl_fls!` call).

I can create a good first issue if this lands and it is not somewhere already.

Cheers,
Miguel


More information about the dri-devel mailing list