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
I personally think these constants should be actual arrays (because it's much easier to get a slice from an array than vice versa), but I'm not sure how feasible that is in current stable Rust.
The text was updated successfully, but these errors were encountered:
Wow, I was about to write the same issue. What a coincidence!
You're right, making them true arrays won't work yet, since associated types aren't allowed to depend on associated constants. A workaround would be to make the array length a generic parameter of the trait, but that's pretty unwieldy, in addition to being semantically completely wrong.
I would be in favor of the macros also generating an inherent associated constant which is a true array. That way we can at least use the constant length in non-generic code.
There was discussion when the features were added about slices vs arrays. Like @T0mstone said, associated constants still aren't great to use. It also makes adding a new variant to an enum a breaking change because the length of the array changes, but slices don't have that issue.
The incorrect documentation:
strum/strum_macros/src/lib.rs
Line 169 in 2056939
strum/strum_macros/src/lib.rs
Line 215 in 2056939
strum/strum/src/lib.rs
Line 220 in 2056939
The actual types:
strum/strum/src/lib.rs
Line 217 in 2056939
strum/strum/src/lib.rs
Line 227 in 2056939
I personally think these constants should be actual arrays (because it's much easier to get a slice from an array than vice versa), but I'm not sure how feasible that is in current stable Rust.
The text was updated successfully, but these errors were encountered: