-
Notifications
You must be signed in to change notification settings - Fork 51
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 [value; N]
syntax support for array_vec!
#118
Conversation
Also implement the `($array_type:ty)` form by just calling `default()` immediately, which makes more sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it, but I'm gonna ping Nemo as well for a double check.
Implementation looks fine, but it seems weird to support this syntax for |
I can add that as well, if you'd like. |
Also make the same improvement to the `($array_type:ty)` macro variant that I did for `array_vec!`.
Ok, added it for |
// Given that this works:
let vec: TinyVec<[f32; 4]> = tiny_vec![1.1, 1.1, 1.1];
// Should this work:
let vec: TinyVec<[f32; 4]> = tiny_vec![1.1; 3]; |
For both ArrayVec and TinyVec? |
hmm, that's a very good question. |
The first form works for both, so if it's possible (/easy enough) it seems good to have the second form for both. |
@slightlyoutofphase Hi, looks like we all forgot about this a bit. did you want to add that one final macro variant to this PR? Or I can just merge it now. |
oh, forgot to say at the time. near as i can tell it looks like the requested style was already implemented by the time it was asked. |
(I also just realised that the inverse could be supported by |
Hey guys, sorry I didn't get back to you. Basically, after playing around with a bunch of things, I found that it isn't quite possible to make the code example given by @Nemo157, that is, this: // Given that this works:
let vec: TinyVec<[f32; 4]> = tiny_vec![1.1, 1.1, 1.1];
// Should this work:
let vec: TinyVec<[f32; 4]> = tiny_vec![1.1; 3]; work at the moment. The compiler isn't quite smart enough currently to see through the ambiguity such that both versions can exist and work in their appropriate contexts at the same time. If it gets to the point where I think this can be done though, I'll for sure come back and add it for you if you want. |
Closes #117. I also improved one of the other variants of the macro a little bit while I was at it.