-
Notifications
You must be signed in to change notification settings - Fork 23
-
I may be missing something basic, but is there a reason that the implementations for the individual Arraysizes (i.e. U2, U3, ...) are all done manually? I understand that they are generated, but that is beside the point.
For the ArrayLength and Unsigned traits in generic_array and typenum respectively the implementations are done on UInt<T, B> and UTerm which allows any created value to automatically support the traits. In contrast hybrid_array::ArraySize only works for the explicitly handpicked values in sizes.rs.
If there is an obvious reason that this is impossible / overly complex for this crate I apologize, but if not, this would be useful to prevent future requests for the addition of custom ArraySizes.
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 2 comments
-
It's a consequence of Array being a wrapper around built-in arrays. Yes, because of that we lose flexibility of generic-array, but on the other hand we do not have complexity of its expanded code.
Beta Was this translation helpful? Give feedback.
All reactions
-
❤️ 1
-
Yeah, like @newpavlov said each trait impl provides a specific concrete [T; N] array size, so it's the linkage between typenum sizes and core arrays, and what allows us to write most of the other trait impls using const generics.
Unfortunately this leads to one trait impl per size, which means the more sizes we add, the more it impacts compile times, which has been a frustrating tradeoff.
See also: #66
Beta Was this translation helpful? Give feedback.