arraystring
arraystring copied to clipboard
use stabilized const generics instead of typenum
I wonder whether it'd be possible to substitute the typenum crate with the subset of const generics stabilized since Rust 1.51.
The main hurdle I see is that the new const SIZE parameter must be usize since it can't be casted later to u8, so if there has to be a 255 limit it may have to be checked dynamically.
The main problem of using arrays of const generic size, is that we must use usize everywhere, since casting from the generic argument is not allowed yet. That in turn increases the minimum size of ArrayString from 1 byte to 4 bytes in 64-bit systems. 16 bytes minimum.
The crate would therefore become less useful for small sized static strings, which I believe is the most important usecase.
I'm closing this. Until the necessary ability to cast const generic attributes arrives to stable I don't think there's a better solution that the current one.
Somehow I only got notified about this issue today.
The maximum size is not a restriction and I'm open to those changes. But honestly, I haven't put a thought into this crate in a couple of years.
So if you can provide a PR with the changes I'm willing to review and accept it.
typenum and having to manually implement the trait for each of its types slows compilation down heavily, so removing it would be great.
Ok, i did suggest something but it depended on generic const expr which is still unstable. Even if the size is > 255, all operation sizes are runtype checked anyway so if N > 255 it's just gonne fail at runtime like if it was N = 255.