Description
There are lots of From
implementations from VariantArray
to Packed*Array
:
impl From<&Array<Variant>> for PackedByteArray {...}
impl From<&Array<Variant>> for PackedColorArray {...}
...
This is of course incorrect, as the variants may hold different types and From
must be infallible.
They are implemented here:
gdext/godot-core/src/builtin/macros.rs
Lines 126 to 142 in f67a1ae
Instead, we should use TryFrom
or a named conversion method. Also, we could add infallible conversions from concretely typed arrays, e.g. Array<Color>
<-> PackedColorArray
in both directions. Right now, there is only PackedColorArray -> VariantArray
.
Overall, From
/TryFrom
is probably OK here, but named methods are a potential alternative. We need to keep in mind that there are other conversions, e.g. between slices, Vec
and so on, so maybe enabling generic programming is beneficial here.