On Sun Sep 21, 2025 at 3:22 AM JST, Joel Fernandes wrote:
> The bitfield macro's setter currently uses the From trait for type
> conversion, which is overly restrictive and prevents use cases such as
> narrowing conversions (e.g., u32 storage size to u8 field size) which
> aren't supported by From.
>
> Replace 'from' with 'as' in the setter implementation to support this.
>
> Suggested-by: Yury Norov <[email protected]>

Can you add a `Link: ` tag to the discussion for context?

But I am not really convinced this is needed or desirable at all. Where
would it make sense to define a field that is larger that its containing
type? This looks like it can introduce confusion or errors. It's already
not ideal that we can pass values that would be truncated; but this
makes it worse.

Anyway, if we decide to keep this, I think you want to remove the 

+//!   Note that the compiler will error out if the size of the setter's
arg exceeds the
+//!   struct's storage size.

bit that was introduced in patch 2.

Reply via email to