Closed slightlyoutofphase closed 4 years ago
Implementation looks fine, but it seems weird to support this syntax for array_vec!
and not tiny_vec!
.
Implementation looks fine, but it seems weird to support this syntax for
array_vec!
and nottiny_vec!
.
I can add that as well, if you'd like.
Ok, added it for tiny_vec!
as well, and added a test.
// 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.
8 | let vec: TinyVec<[f32; 4]> = tiny_vec![1.1; 3];
| ----------------- ^^^^^^^^^^^^^^^^^ expected an array with a fixed size of 4 elements, found one with 3 elements
| |
| expected due to this
(I also just realised that the inverse could be supported by tiny_vec!
(and not array_vec!
): let vec: TinyVec<[f32; 4]> = tiny_vec![1.1; 5];
, going directly to an allocation).
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.