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

Support any array length via const generics #111

Open
archseer opened this issue Sep 24, 2021 · 1 comment
Open

Support any array length via const generics #111

archseer opened this issue Sep 24, 2021 · 1 comment

Comments

@archseer
Copy link

1.51 stabilized support for const generics on arrays, that way array length can be supported.

I had the need for [u8; 65] (64 byte signature + nonce) but had to rely on Vec<u8> for now since we currently only generate implementations for sizes 1-32.

@GREsau
Copy link
Owner

GREsau commented Jun 5, 2024

This is a similar problem to serde-rs/serde#1937 - serde implements Serialize for [T; 0] even when T doesn't implement Serialize, so I followed the same pattern with JsonSchema. Unfortunately, this makes it difficult to use const generics, because in the general case, [T; n] requires T: JsonSchema, which would then mean that [T; 0] would also require T: JsonSchema.

That would be a breaking change (which we can do in 1.0), and a divergence from how serde works, although I don't think it's unreasonable - after all, how often to people really generate a JSON schema for [T; 0] where T doesn't implement JsonSchema?

But out of interest, what's your use-case? As I understand it, you can't be using serde to serialize/deserialize that type because it doesn't use const 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

No branches or pull requests

2 participants