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
(There is no reason why this needs to be a method (not even a const-fn method), and it's unelegant to have both a method and a non-associated constant.)
An associated constant is the right way to express this.
Use an associated constant for EnumCount:
This would replace both the
count()
methodstrum/strum_macros/src/macros/enum_count.rs
Line 23 in a20ee16
and the
<enum-name>_COUNT
constantstrum/strum_macros/src/macros/enum_count.rs
Line 29 in a20ee16
and it works on stable since 1.20.
(There is no reason why this needs to be a method (not even a const-fn method), and it's unelegant to have both a method and a non-associated constant.)
An associated constant is the right way to express this.
Related discussion: #58 #15 (comment)
Btw, this was motivated by my real-world use case that is currently not possible with
EnumCount
, I need to define the following:It's not possible because
count()
is not a constant.The text was updated successfully, but these errors were encountered: