-
Notifications
You must be signed in to change notification settings - Fork 76
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
Project future post-1.51.0 and min_const_generics, possible deprecation? #115
Comments
There are tricks folks play with this crate that do not work with min_const_generics, but one expects this crate incurs a larger compile time penalty, so.. I'd think changes here sound painful, but ideally generic_array users should transition themselves to min_const_generics if possible, and especially remove generic_array from public interfaces. |
When I have time and people desire it, I could attempt a separate crate with a (mostly) drop-in pub struct GenericArray<T, const N: usize>([T; N]); and implement most/all of the existing If a user has |
Came across a use-case today that doesn't work with trait Trait {
const N: usize;
fn foo() -> [f32; Self::N];
} We couldn't really explain why Rust won't accept this, but it was argued that you'd sometimes want it to be an associated const, not a const generic, because—just like with associated types—you want only one implementation of this trait per type. Rust is having none of it:
Which seems a bit off to me, since I would like to draw a parallel to associated types, which you can use in that manner. use generic_array::{ArrayLength, GenericArray};
trait Trait {
type N: ArrayLength<f32>;
fn foo() -> GenericArray<f32, Self::N>;
} So that's one reason to keep the old way around. At least I suspect that if The motivating example compiles with |
Revisiting this two years later, const-generics are still too minimal to fully replace generic-array. However, with #137 just now we have the opportunity to make generic-array 1.0 much more ergonomic overall. For anyone watching this issue, please suggest any additional breaking changes in #101 Will consider reopening if Rust ever has full const-generic support. |
I wish generic-array occurred less in public interfaces. It still delivers poor ergonomics, even if multiple types never occur. |
Now that
min_const_generics
has been stabilized in Rust 1.51.0, should we begin deprecating this crate? We can use the existingbuild.rs
script to check the version number and only generate the deprecation on post-1.51.0 versions.However, an alternative would be to port much of this crate's functionality to a new (simpler) array wrapper type that fully utilizes const generics, to work alongside and ease replacement of existing code.
Please feel free to submit your thoughts on the matter.
The text was updated successfully, but these errors were encountered: