Re: [PATCH 03/12] rust: num: add Bounded::shr_exact

From: Alexandre Courbot

Date: Fri Aug 07 2026 - 10:31:41 EST


On Wed Aug 5, 2026 at 2:44 PM JST, Eliot Courtney wrote:
> Add `shr_exact` in the vein of `try_shrink` which shifts a bounded right
> only if it loses no set bits. This is useful for getting a shifted down
> integer while simultaneously checking that it's aligned.
>
> Signed-off-by: Eliot Courtney <ecourtney@xxxxxxxxxx>

Maybe it is worth briefly mentioning that an equivalent method exists in
the standard library (in nightly) for primitive types [1].

With the missing `#[inline]` mentioned by Sashiko fixed,

Acked-by: Alexandre Courbot <acourbot@xxxxxxxxxx>

[1] https://doc.rust-lang.org/std/primitive.u32.html#method.shr_exact