-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
implement Default
for arrays
#25169
Comments
What's special about N=0..33? |
Due to lack of generics over integers, we cannot implement it for all N. Typically traits on arrays in the standard library are implemented for N=0..33, see for example |
I looked at this a bit today and I'm stuck. Here's one way to do it, but it requires an extraneous impl<T: Copy + Default> Default for [T; $N] {
#[inline]
fn default() -> [T; $N] {
[Default::default(); $N]
}
} Not sure if there's any way to achieve the same effect as array initialization without requiring |
You could write |
I think you have to write it out as |
This was implemented in #27825 and can be closed. |
Something like
for N=0..33 should be added to
src/libcore/default.rs
. The question is how to do that with a macro.The text was updated successfully, but these errors were encountered: