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

postcard-schema: inconsistent schema names for [T] and [T; N] #182

Open
max-heller opened this issue Nov 12, 2024 · 1 comment
Open

postcard-schema: inconsistent schema names for [T] and [T; N] #182

max-heller opened this issue Nov 12, 2024 · 1 comment

Comments

@max-heller
Copy link

Is there a reason for [T]'s schema name to be &[T] while [T; N]'s is [T; N] (no &)? It seems like it'd be more consistent to remove the &.

impl<T: Schema> Schema for [T] {
const SCHEMA: &'static NamedType = &NamedType {
name: "&[T]",
ty: &DataModelType::Seq(T::SCHEMA),
};
}
impl<T: Schema, const N: usize> Schema for [T; N] {
const SCHEMA: &'static NamedType = &NamedType {
name: "[T; N]",
ty: &DataModelType::Tuple(&[T::SCHEMA; N]),
};
}

@jamesmunns
Copy link
Owner

I think that's reasonable. The idea was to make it clear the former is a slice (e.g. with a len), whereas the latter is an array. I don't often use bare unsized slices, so I used &[T] out of habit.

That being said, [T] is probably more consistent.

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