Open YoshieraHuang opened 2 years ago
The problem here is that array_vec! has several ways it can be invoked.
macro_rules! array_vec {
($array_type:ty => $($elem:expr),* $(,)?) => { ... };
($array_type:ty) => { ... };
($($elem:expr),*) => { ... };
($elem:expr; $n:expr) => { ... };
() => { ... };
}
Unfortunately, in this situation it seems to be doing a partial match on the 2nd case, ($array_type:ty) => { ... };
, which then fails because that's not actually what you wanted.
I don't think there's an easy fix here, because changing the ordering of the match arms can break other people's code instead.
I'll link this issue in the discord and perhaps a macro expert can swoop in and solve the problem.
In the mean time, array_vec!([(f32,f32); 3] => (2.0, 2.0), (2.0, 2.0), (2.0, 2.0))
is more verbose but does work how you want (playground example).
This expression tries to construct an
ArrayVec
with element type(f32, f32)
but cannot compile:The error goes like:
Meanwhile, the
vec!
macro can handle this well.