You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The parameter of the generated from_repr has the type specified by the repr on the enum. However the COUNT associated const always has the type usize. This requires casts when composing the two (for example when doing arithmetic to get the prev/next variant).
I think it makes sense to also give COUNT the type from the repr (and usize of not specified). This is obviously a breaking change but it'll only affect people who specify a repr.
The most common repr type will probably be u8 which can convert to usize infallibly so if people specify #[repr(u8)] but want count as usize, they can convert using .into() without any unwraps. This is not the case currently - converting COUNT to the type required by from_repr is a fallible conversion and therefore needs unwrapping.
The text was updated successfully, but these errors were encountered:
The parameter of the generated
from_repr
has the type specified by the repr on the enum. However theCOUNT
associated const always has the typeusize
. This requires casts when composing the two (for example when doing arithmetic to get the prev/next variant).I think it makes sense to also give
COUNT
the type from the repr (andusize
of not specified). This is obviously a breaking change but it'll only affect people who specify a repr.The most common repr type will probably be
u8
which can convert tousize
infallibly so if people specify#[repr(u8)]
but want count asusize
, they can convert using.into()
without any unwraps. This is not the case currently - convertingCOUNT
to the type required byfrom_repr
is a fallible conversion and therefore needs unwrapping.The text was updated successfully, but these errors were encountered: