For instance, you cannot currently do
let v = vec![Vector3::new(1.0, 2.0, 3.0)];
let packed: PackedVector3Array = v.into();
This could be fixed with a From<Vec<Vector3>> impl for PackedVector3Array.
In general since packed arrays are very similar to Vec we could also take inspiration from what Vec has implemented.
See discussion below for more details.
Traits to implement:
From<Vec<T>>
From<[T; N]>
From<Array<T>>
From<PackedTArray> for Array<T>
Index and IndexMut, i think we can use I: SliceIndex like Vec does.
IntoIterator
Write, for PackedByteArray only but preferably have a use-case first
Other trait impls we can consider:
Deref and DerefMut to [T]. may conflict with Godot's api for packed arrays
From<Box<[T]>>, From<VecDeque<T>>. We can already do this with collect()
AsRef<[T]>, AsMut<[T]>, Borrow<[T]>, BorrowMut<[T]>. Should have a use-case first
Additionally we apparently have From<&VariantArray> for PackedVector3Array etc, which is wrong. (looking at the implementation this might actually be UB).
For instance, you cannot currently do
This could be fixed with a
From<Vec<Vector3>>impl forPackedVector3Array.In general since packed arrays are very similar to
Vecwe could also take inspiration from whatVechas implemented.See discussion below for more details.
Traits to implement:
From<Vec<T>>From<[T; N]>From<Array<T>>From<PackedTArray> for Array<T>IndexandIndexMut, i think we can useI: SliceIndexlikeVecdoes.IntoIteratorWrite, forPackedByteArrayonly but preferably have a use-case firstOther trait impls we can consider:
DerefandDerefMutto[T]. may conflict with Godot's api for packed arraysFrom<Box<[T]>>,From<VecDeque<T>>. We can already do this withcollect()AsRef<[T]>,AsMut<[T]>,Borrow<[T]>,BorrowMut<[T]>. Should have a use-case firstAdditionally we apparently have
From<&VariantArray> for PackedVector3Arrayetc, which is wrong. (looking at the implementation this might actually be UB).