arrayvec icon indicating copy to clipboard operation
arrayvec copied to clipboard

Make length type generic

Open JakkuSakura opened this issue 2 years ago • 8 comments

It's really a lot of work being done This PR resolves #247, supersedes #248
However, some things are broken: type inference won't work for ArrayVec::from([0; N]) like before some functions like len() are no longer const, unless nightly is enabled

This PR is expected to be merged after #255

JakkuSakura avatar Dec 21 '23 02:12 JakkuSakura

I'm really interested in this, but it seems like there are conflicts that need to be resolved @JakkuSakura?

GnomedDev avatar Mar 29 '24 13:03 GnomedDev

Hi, while it's easy to resolve the conflicts, the potentially breaking semantics should be carefully evaluated by the author, before merging

JakkuSakura avatar Mar 30 '24 08:03 JakkuSakura

Okay, I've opened a PR on your repo with some fun type system hacks that fix the inference for From<[T; CAP]> in a lot of cases, and also makes the default use the proper type instead of u32 in a lot of cases. If/When trait associated type defaults are a thing, this will become basically perfect, but as-is it needs users to provide LenT if the CAP value isn't in the predefined list of CAP => LenT.

GnomedDev avatar Mar 31 '24 00:03 GnomedDev

It's almost perfect

        let string = ArrayString::<11>::from_byte_string(b"hello world").unwrap();

the only tests that failed was ArrayString without <11>. it's related to the way rust handles inferred type with default type generics.

JakkuSakura avatar Apr 05 '24 09:04 JakkuSakura

Hi folks, I'm also really interested in this feature. Is there anything I could help with to move this forward?

honzasp avatar Aug 08 '24 09:08 honzasp