-
Notifications
You must be signed in to change notification settings - Fork 212
Converting TypedArray
to Vec
fails unexpectedly
#806
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
Comments
In GDScript, there are two ways of representing arrays of strings:
The two are not interchangeable, which is why you get the error when you try to extract a So this is not a bug, but I agree with your observation that conversion between the two should be easier. There is currently quite a bit of confusion about different types and their convertibility in the godot-rust API. Part of it has to do with documentation, but an important part is also naming, which we're trying to address in #773. Regarding this issue, since we already have |
The idea with
But am I trying to extract a
In the latter case it is logical that the conversion tries to extract a dynamically-typed |
Having a separate code path in To convert a |
To make sure I understand correctly: By full specializations you mean the 7 specializations for
As long as it is documented somewhere (and perhaps we can simplify it so that the temporary isn't needed) that would be fine as well. From a user perspective it is just slightly weird that it is harder to convert a |
By "full specialization" I mean
I agree that wrapping that in a |
There is a high likelihood that I'm simply doing something wrong (perhaps related to #774), but it still feels like a potential bug.
Basically my goal is to convert a
TypedArray<GodotString>
toVec<String>
. After studying potentially relevant trait implementations, it occurred to me that I'll have to take the detour throughVariant
, because theToVariant
is implemented forTypedArray
andFromVariant
is implemented forVec
:However this panics with:
Shouldn't a
StringArray
be convertible as well, in particular because homogeneity is guaranteed?Side note: For now I'm using this work-around
which feels a bit clumsy, because the
read()
has an unusual name and the mandatory temporary avoids doing it in one expression I guess.Since the conversion from
Vec
toTypedArray
is well documented here, it would be great to give a short hint about the reverse direction as well. Or alternatively somewhere here in the book.The text was updated successfully, but these errors were encountered: