Re: [PATCH] rust: num: bounded: add safety comment for Bounded::__new

Hsiu Che Yu
2025-12-01T13:26:36Z

On Mon, Dec 01, 2025 at 10:12:27AM +0000, Alice Ryhl wrote:
>I disagree. For the same reasons as str::from_utf8_unchecked, this
>should also be unsafe. It creates a value that violates invariants,
>which may be used to trigger UB combined with other safe code.
>
>Alice

I understand. Once the caller passes a value that cannot be represented
with N bits, the type invariant is violated. Keeping this function safe
could allow callers to overlook this critical requirement.

Thank you for the feedback. I will submit v2 with the necessary changes
and improved documentation.

Best regards,
Hsiu Che Yu