-
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
Implemented Default for arrays up to [T; 32] #27825
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @brson (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. The way Github handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
I'm not sure how exactly |
Could this reduce the verbosity a bit by taking a strategy similar to this |
@alexcrichton I don't think so, because array syntax requires that each successive macro invocation insert a different integer literal. I have managed to shorten it by removing all the EDIT: well, maybe there's a way that's a bit more complicated than that, let me sketch it out and see. @marcusklaas the problem with creating array literals is that for each item in the array, the macro invocation needs a token to expand to (unless the array is restricted to Not clear on the stability tagging scheme and if this impl needs to be tagged with something. |
@withoutboats You're almost there! You can 'dynamically' create the integers by using I'll try to make something in play. edit2: it works: https://play.rust-lang.org/?gist=33022e935f049b9a8e8c&version=nightly |
Okay, this should be good now. I had no idea that |
Thanks! Could you also:
|
f26f7b9
to
975a8ed
Compare
Done. 😄 |
Implemented Default for arrays up to length 32 where T: Default using an additional macro.
Can you give an example of usage? My attempt:
Doesn't seem to work. I'm on |
@andrey-gvrd
Use |
@andrey-gvrd The way to use this is actually |
Implemented Default for arrays up to length 32 where T: Default using an additional macro.