Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make length type generic #256

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

JakkuSakura
Copy link
Contributor

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 JakkuSakura force-pushed the generic-length-type-over-new-layout branch from 812ca47 to 4fb1f1b Compare December 29, 2023 13:59
@JakkuSakura JakkuSakura force-pushed the generic-length-type-over-new-layout branch from 4fb1f1b to eefee31 Compare December 29, 2023 14:00
@GnomedDev
Copy link

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

@JakkuSakura
Copy link
Contributor Author

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

@GnomedDev
Copy link

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.

@JakkuSakura
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can I change LenUint to u8?
2 participants